in reply to Opening Unknown Filenames
1. Open Directory /var/log/cr_userGood idea, but your code doesn't follow it. Instead of opening and reading the directory, you run ls and read it's output. I recommend something like:
Next, your foreach doesn't specify it's list. It should readmy $dir = '/var/log/cr_user'; opendir( my $dh, $dir ) or die "failed opening directory $dir: $!"; my @files = grep { ! /^\./ } readdir( $dh ); # skips dirs . and .. and + all dotfiles # faster but less readable would be something like grep { substr( $_, +0, 1 ) ne '.' ) }
Same forforeach my $file ( @files ) {
I added the my declarations in there, too, you're need to declare all your vars that way for strict mode to work.foreach my $account ( @account ) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Opening Unknown Filenames
by diotalevi (Canon) on Jul 05, 2003 at 13:02 UTC | |
by Aighearach (Initiate) on Jul 06, 2003 at 03:42 UTC | |
by diotalevi (Canon) on Jul 06, 2003 at 03:59 UTC | |
|
Re: Re: Opening Unknown Filenames
by hiddenlinux (Acolyte) on Jul 05, 2003 at 10:33 UTC | |
by chromatic (Archbishop) on Jul 05, 2003 at 17:01 UTC |