CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Pater to get filename

 



HTTP404
Deleted

Mar 19, 2001, 4:26 AM

Post #1 of 3 (172 views)
Pater to get filename Can't Post

Dear Friends
i have path like this

e:/dir/dir1/dir2/text.txt

what patter do i have to use to get filename (text.txt)

thank you very much



japhy
Enthusiast

Mar 19, 2001, 7:21 AM

Post #2 of 3 (169 views)
Re: Pater to get filename [In reply to] Can't Post

There's a standard module for that, called File::Basename. There are examples in its documentation. Or, you can roll your own:


Code
# regex 
($file) = $path =~ m!([^/]+)$!; # last string of non-/ chars

# non-regex
$file = substr $path, rindex($path, '/') + 1;

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


HTTP404
Deleted

Mar 20, 2001, 11:56 AM

Post #3 of 3 (163 views)
Re: Pater to get filename [In reply to] Can't Post

thnx pal


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives