in reply to Re: Extract string from rear of string
in thread Extract string from rear of string

or
$ext = (split /\./, $fname)[-1];

But neither take note of the fact that the file might not have an extention...

Replies are listed 'Best First'.
Re: Extract string from rear of string
by hacker (Priest) on Dec 28, 2001 at 15:20 UTC
    ..or more than one dot... like linux-2.4.17.tar.gz
      Begging your pardon, but the split shown returns the last bit of stuff after the final dot, which I think complies with the rather vague request of getting the extension. In your example, the extension is 'gz' after all. That's the beauty of negative indices, they work from the other end.