in reply to Removing digits from a string
As someone else mentioned, I'm not sure the word "truncate" quite fits. Here's a solution that gives you a bit more flexibility:
This will result in the scalar $dateStamp containing "20130101" and $basename containing "Customer100". The presumption I made (you didn't specify otherwise) was that your filenames all have the extension "imp" and as long as they do the regex I supplied you will work. I leave it as an exercise in intellect for you to modify the regex if there are other extensions involved.| hand waving here... my $fname = "20130101Customer100.imp"; # gotta go somewhere.. $fname =~ m@^(\d+)([A-Za-z0-9]+)\.imp$@; # Capture what we are looking + for... my $dateStamp=$1; my $basename=$2; | do something with this.
|
|---|