in reply to Help in using backtick operator
Not sure if I understand your question correctly, but I would start with:
- chomp $date; , or better:
- build $date without shelling out (e.g. POSIX::strftime or localtime and sprintf)
- using a correct regular expression, e.g. if ($file =~ m/AAAA\*.*?$date/) { ... }
Update: Missed, that there is a literal * in the filename. \$ matches literal $, not $date. Non-greedy matching is probably not necessary here, but does no harm (in response to question below). It would be a good idea to also anchor the regexp. - (also add usestrict; and use warnings; if not already done so)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help in using backtick operator
by manutd (Initiate) on Oct 31, 2011 at 20:33 UTC |
In Section
Seekers of Perl Wisdom