in reply to Regular Expressions Matching with Perl

Are there always 8 columns of data? Is the file name always last?

If so (untested) -
$filename = (split( /\s+/,$line, 8 ))[-1]
If it's always at a certain index, you could go off of that, also. Regexp's are useful, but not always necessary!

Update:
As ikegami points out - this will not work quite the way you want because of the perceived "null field" in front of the the leading spaces as shown in split

$filename = (split( ' ',$line, 8 ))[-1]

Replies are listed 'Best First'.
Re^2: Regular Expressions Matching with Perl
by ikegami (Patriarch) on Apr 20, 2005 at 17:42 UTC
    This won't work because of the leading spaces. See my reply for the fix.
Re^2: Regular Expressions Matching with Perl
by nimdokk (Vicar) on Apr 20, 2005 at 17:49 UTC
    Right, and when I tried it on a sample containing three files, it worked perfectly on the first line, but on the second two, it grabbed the 7th column as well. It looks like this is definitly taking me in the right direction. I'd tried the split route first but the spaces in the filename would throw everything off. I'll play around with some of these suggestions and see what I can come up with. Thanks for the quick responses.

    Update: I tried the updated line and it worked beautifully, need to do some more testing, but I think I've got a winner here. Thanks again.

Re^2: Regular Expressions Matching with Perl
by nimdokk (Vicar) on Apr 20, 2005 at 17:41 UTC
    It will always be in the 8th column - I'll give that a shot and see. Just tried my regexp and it didn't do a thing. I'll give this a shot and see what happens.