in reply to Help with grep

Keep an eye on the asterisks that you are putting in $search_string, too. An asterisk means 'match the preceeding element 0 or more times, so the asterisk in 'C04*' means 'match the digit 4 zero or more times'.

An asterisk in 'C04\w*' would mean 'match any alphanumeric character (or underscore) zero or more times.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

Replies are listed 'Best First'.
Re^2: Help with grep **RESOLVED**
by LeeC79 (Acolyte) on Jul 16, 2004 at 17:47 UTC
    Thanks Art! This did it:
    my $search_string = 'C04\w*'.substr($year, 2, 2).$mon.$day.'\w*.ORD_AP +I'; my $dir = 'C:\\done\\'; my $file; my $i; opendir DIR, $dir; my @file = grep {/^$search_string/} readdir DIR; closedir DIR; foreach $file(@file){ print $dir.$file[$i]."\n"; $i++; }