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: Intermediate:
splitting ...

 



melz
Novice

Apr 12, 2000, 10:31 AM

Post #1 of 3 (609 views)
splitting ... Can't Post

let's say i have a string in a file:

/home/somewhere/out/there/file.txt

how can i just get "file.txt" from the line. any ideas? thx in advance!



daniel_lsl
Deleted

Apr 12, 2000, 7:29 AM

Post #2 of 3 (609 views)
Re: splitting ... [In reply to] Can't Post

This should solve your problem.

$home = "/home/somewhere/out/there/file.txt";
if ($home =~ m/\/+([^\/]+)$/) {
$file = $1;
print "$file\n";
}

Daniel


melz
Novice

Apr 12, 2000, 8:33 AM

Post #3 of 3 (609 views)
Re: splitting ... [In reply to] Can't Post

great, it works.

ok, how about this?

what if the path is a Win32 path, ie:

c:\Someplace\notice space\test.txt

what expression do i use now?

btw, is it possible to explain the match expression you used? i sort of want to know what it means.

thx for your help!

m.

 
 


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

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