in reply to Exceeding CPU Limit
Can you refactor your code a little bit? Maybe this function helps you.
perltidy is a great tool if you are too lazy to format your code nicely.use strict; use warnings; use English qw( -no_match_vars ) ; use Data::Dumper; sub get_files_in_directory { my ( $dir, $filter ) = @_; opendir my $DIR, $dir or die "Can't open $dir: $OS_ERROR"; my @files = grep {/$filter/} readdir($DIR); closedir $DIR; return @files; } # print every file in tmp starting with 'N' print Dumper( get_files_in_directory( '/tmp', qr/^N/ ) );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Exceeding CPU Limit
by davidrw (Prior) on Mar 24, 2006 at 16:10 UTC |