in reply to Truncating Filename string

You could try something like this:

while(<DATA>) { if($_ =~ m/\/([\w\d\.]+)$/) { print "$1\n"; } } __DATA__ /blah/blah/blah/blah/file1.pl /blah/blah/file2.pl /blah/blah/blah/blah/blah/blah/blah/file3.pl

This will result in the desired output.

--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re: Re: Truncating Filename string
by graff (Chancellor) on Jan 28, 2004 at 02:43 UTC
    All code is usually tested, but rarely trusted.

    You said it (so I'm just repeating what you said ;^).

    m/\/([\w\d\.]+)$/
    Remember that "\w" represents alphanumerics and underscore -- no need to add "\d" to a character class when "\w" is already there.

    This will result in the desired output.

    ... for the three examples provided, but not for file names that contain dashes, plus-signs, tildes, colons, ... Better not to try to match the file name content (since you don't need to).