Would I be correct in inferring from your code that the "account number" is always at the start of the filename and followed by an underscore? In that case, a simple index test would do (and I think should be pretty efficient). Something like this:
#!/usr/bin/perl use strict; use warnings; my $filename = "000231263444_01_XY_20130110_061717.txt"; my $accountnumber = '000231263444'; if (index($filename, "${accountnumber}_") == 0) { print "Found\n"; } else { print "Not found\n"; }
In reply to Re: Checking number in file name
by hippo
in thread Checking number in file name
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |