in reply to Re: Define regex substitution $1,$2,... from a string
in thread Define regex substitution $1,$2,... from a string

Thank you for your suggestion.

Could you kindly let me know what's wrong with my commands when I'm trying reproduce your example as below?

@$> perl -e '$_="h:/p/f.zip";$replace=q[qq<x?f=$1>];s/([^/]+)$/$replac +e/e+e;say' Scalar found where operator expected at -e line 1, near "s/([^/]+)$/$r +eplace" Final $ should be \$ or $name at -e line 1, within string syntax error at -e line 1, near ";s/([^/]+)$/" Execution of -e aborted due to compilation errors. @mnsdev10> perl -v This is perl, v5.8.8 built for sun4-solaris Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. @$> perl -e '$_="h:/p/f.zip";$replace=q[qq<x?f=$1>];s|([^/]+)$|$replac +e|ee;say' @$>

Replies are listed 'Best First'.
Re^3: Define regex substitution $1,$2,... from a string
by choroba (Cardinal) on May 24, 2016 at 07:52 UTC
    There's no e+e . Also, if you want to use s/// with slashes, you need to backslash literal slashes. Moreover, there's no say in 5.8.8. Use perl -l and print instead.
    perl -le '$_="h:/p/f.zip";$replace=q[qq<x?f=$1>];s=([^/]+)$=$replace=e +e;print'

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,