in reply to strip substring from long string

$a='/usr/local/prj/code/prog/prog1'; ($path)=$a=~m#.+/(.+?)$#; print $path;

Replies are listed 'Best First'.
Re^2: strip substring from long string
by Roy Johnson (Monsignor) on Mar 03, 2005 at 12:15 UTC
    The leading dot-plus is unnecessary. In fact, you can just get all the non-slash characters leading up to the end of string:
    ($basename) = $a =~ m#([^/]+)$#;

    Caution: Contents may have been coded under pressure.