Some further thoughts on this.
If $pref is supposed to hold 001, you're removing all digits from it with:
$pref =~ s/[0-9]+//gi;
I'm wondering if that substitution is supposed to be the same as the previous two (i.e. s/[^0-9]+//gi). If not, the 'i' (case insensitivity) modifier is pointless.
On a more general point regarding those substitutions, s/chars//g is a slow way to do it and s/chars//gi is even slower. A transliteration (or, in this case, transobliteration) is faster. See the "Search and replace or tr" section of "Perl Performance and Optimization Techniques".
You have six instances in your code. Here's how you could replace them:
$ perl -le 'my $x = "1q2w3e"; $x =~ y/0-9//cd; print $x' 123
$ perl -le 'my $x = "1q2w3e"; $x =~ y/0-9//d; print $x' qwe
$ perl -le 'my $x = "ÞORNþorn"; $x =~ y/Þþ//d; print $x' ORNorn
In case you didn't know, y/// and tr/// are synonymous. See "perlop: Quote-Like Operators" for more details.
-- Ken
In reply to Re: Traverse directory backwards based on file
by kcott
in thread Traverse directory backwards based on file
by subhash1198
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |