Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Answer: How to extract the substring from a delimiter (dot) to end of string?

by ZZamboni (Curate)
on May 08, 2000 at 21:56 UTC ( #10639=categorized answer: print w/replies, xml ) Need Help??

Q&A > data formatting > How to extract the substring from a delimiter (dot) to end of string? - Answer contributed by ZZamboni

In the spirit of TIMTOWTDI, you could also do:

( $extension ) = $string =~ /([^.]*)$/;

The above will give you the whole string if it does not contain any dots. If you want the result to be undef if there are no dots, you could use:

( $extension ) = $string =~ /\.([^.]*)$/;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: choroba: Well, at least the above is user-defined, not implicitly by Perl ;)
LanX globalization is evil! Lets Perlxit!
[stevieb]: "Yeah, let's ban dot in INC, but add glob to it!" LOL!!!
[LanX]: Oxfam: The local corner shop where I buy bread probably pays a higher tax rate than Apple.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2017-01-19 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.