Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: extract file name from a dynamic path

by SFLEX (Chaplain)
on Sep 06, 2008 at 18:07 UTC ( [id://709537]=note: print w/replies, xml ) Need Help??

in reply to extract file name from a dynamic path

You could use a module or write the 1 line of code to do the job.
Here's another way.
my $file_name = ''; $tst = 'test\testweb\testlibb\file.-finaltestfla.jar'; $file_name = $1 if ($tst =~ m/\A\S+\\(.*?\.jar)\z/i); print $file_name . "\n" . $tst;

Replies are listed 'Best First'.
Re^2: extract file name from a dynamic path
by jwkrahn (Abbot) on Sep 06, 2008 at 18:32 UTC
    john@perl:~$ perl -le' my $file_name = q[]; $tst = q[test\test web\test libb\file.-finaltestfla.jar]; $file_name = $1 if ($tst =~ m/\A\S+\\(.*?\.jar)\z/i); print $file_name . "\n" . $tst; ' test web\test libb\file.-finaltestfla.jar test\test web\test libb\file.-finaltestfla.jar
      Thank you all!
      the original path didn't have spaces

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-06-20 07:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.