in reply to Regex for ignoring paths

I would do something like this :
use strict; use warnings; my $fullname = '/windows/system32/cmd.exe'; my $p = rindex($fullname, '/'); my $filename = ++$p ? substr($fullname, $p) : $fullname; print "$fullname\n\n$filename"; exit;
This is a simple & fast solution.

Replies are listed 'Best First'.
Re^2: Regex for ignoring paths
by Anonymous Monk on Oct 31, 2018 at 20:39 UTC
    how does this answer the question?
      He wants to extract file names from paths. I just want to point out that there is an easy way to do this without using regex.
        He wants to extract file names from paths.

        nope