in reply to Re^2: selcting a specific file
in thread selcting a specific file
Your code won't compile. That's not very dire. Just stay comitted to it ;-)
use strict; use warnings; my $path = '/tmp/allfiles'; my $outpath = '/tmp/nonemptyfiles'; opendir my $dh, $path or die $!; my @files = grep /\.log$/ && -f "$path/$_" && !-z "$path/$_", readdir +$dh; closedir $dh; for my $fn (@files){ open my $fr, '<', "$path/$fn" or die "IN: $fn $!"; open my $fw, '>', "$outpath/$fn" or die "OUT: $fn $!";; while( <$fr> ) { printf $fw "$1 $2\n" if /(\S+)\s+(\S+)/ } }
Try to study the example and bear some idomatic expressions in mind like indirect file handles and checks for success ...
Regards
mwa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: selcting a specific file
by Anonymous Monk on Oct 23, 2007 at 00:18 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |