in reply to Reading specific files from a directory
I'm not whether my code is any faster or more optimal than yours; I'll leave that for monks greater than I =) BTW, I'm not sure if it's a typo but:#!/usr/bin/perl -w use strict; my $somedir = "/home/me/lala"; my $file; opendir (DIR, $somedir); while ($file = readdir DIR) { print "$file\n"; if ($file =~ /^example\.\d+\.txt$/) { print " -- FOUND example: $file\n"; } }
should be:open (DIR, $somedir);
opendir (DIR, $somedir);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reading specific files from a directory
by Lexicon (Chaplain) on Mar 12, 2001 at 11:06 UTC |