in reply to Regular expression
Also in the chatterbox, I pointed out File::Basename and File::Spec to you. Both will only work for your filenames if you're on Win32. If you're trying this on a non-Windows platform, the mentioned alternative of using /([^\\+])$//([^\\]+)$/ to extract the filename part will still work, with the minor change of using whitespace instead of end of line as the anchor.
Personally, I would approach your log parsing task by splitting on whitespace and then looking closer at the filename part:
my @entries = split "", $record; if ($record[0] eq 'FRAG') { warn "File is $record[8]"; $record[8] =~ /([^\\+])$/ or die "Malformed file entry: '$record[8]'"; warn "Basename is '$1'"; };
Update: Fixed bad typo that rendered the RE useless.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression
by PugSA (Beadle) on Sep 16, 2008 at 13:38 UTC | |
by shmem (Chancellor) on Sep 16, 2008 at 14:05 UTC |