On Mon, 28 Jun 1999, Vicki Brown wrote: > As should be obvious from some of my other posts, I tend to value Making > the Goal Clearer to the Reader over speed (at least when the speed issue is > nearly moot). Yeah, me too. Whoever wrote the code may not be interested in such things. Or they may have plugged in a regular expression thing from somebody else's code, then stuck in an index because they're not thinking in a Perlish way. I'd go with the latter, judging by the Hungarian naming. > For those who can't recall the original code: > > opendir( dirPhdDir, $phdDirPath ) || die "couldn't open directory"; > while( defined( $szPhdFile = readdir( dirPhdDir ) ) ) { > if ( index( $szPhdFile, ".phd." ) >= 0 ) { > ( $szRoot = $szPhdFile ) =~ s/\.phd\..*$//; > $szRoot =~ s/^.*\///; > if ( ! exists $aPhdFiles{ $szRoot } ) { > $aPhdFiles{ $szRoot } = ""; > } > } > } Two regular expressions and an index, when he only needs one regexp? Ick. Here's my try: opendir(phddir, $dirpath) || die "couldn't open directory"; while (my $fname = readdir(phddir)) { $fname =~ s|^.*/([^/])\.phd\..*$|$1|g or next; $phdfiles{$fname} ||= ''; } closedir(phddir); Is that better? I write a lot of Embperl-based web pages with forms, so I absolutely love the ||= operator. ==== Want to unsubscribe from Fun With Perl? ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org