Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: split string and always get last word

by revdiablo (Prior)
on Mar 02, 2006 at 03:06 UTC ( [id://533797]=note: print w/replies, xml ) Need Help??


in reply to split string and always get last word

Your strings look like paths. If this is the case, you can make your code nicely portable by using File::Spec. Example:

use File::Spec; my $path1 = "./t2"; my $path2 = "/alex/samsung/t2"; my $end1 = ( File::Spec->splitdir($path1) )[-1]; my $end2 = ( File::Spec->splitdir($path2) )[-1]; print "Found $end1 at the end of $path1\n"; print "Found $end2 at the end of $path2\n";

Log In?
Username:
Password:

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

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

    No recent polls found