Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Extract string from rear of string

by Anonymous Monk
on Dec 28, 2001 at 06:34 UTC ( [id://134795]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://134795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found