in reply to Checking number in file name
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Checking number in file name
by Anonymous Monk on May 19, 2013 at 15:46 UTC | |
by hdb (Monsignor) on May 19, 2013 at 17:28 UTC |