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