Next Regular Expression Mastery 56

Backreference Numbering is Lexical

        # $file is "report.pl" or "/usr/local/bin/report.pl"
        ($path, $name, $suff) = $file =~ m{ (.*/)?(.*)\.(.*)};
        /usr/local/bin/  report  .   pl
        -----path------  -name-     suff
              $1           $2        $3
                         report  .   pl
             path        -name-     suff
              $1           $2        $3


Next Copyright © 2002 M. J. Dominus