Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: strip substring from long string

by mlh2003 (Scribe)
on Mar 03, 2005 at 12:00 UTC ( #436168=note: print w/replies, xml ) Need Help??


in reply to strip substring from long string

Another way would be to split based on '/' and get the last element of the array. This is one of the methods that holli suggested (using split). Depending on your OS, the path separator may change - in which case the split character needs to reflect that:
my $full_file = '/usr/local/prj/code/prog/prog1'; print "Filename is: " . (split '/', $full_file)[-1];
--------------------
mlh2003

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-10-26 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (91 votes). Check out past polls.

    Notices?