s0ttle has asked for the wisdom of the Perl Monks concerning the following question:
but I cannot seem to find a way to get this to work:perl -le '$_=q(ab cdefg);s/(^\w+)/$1,/;print;'
I thought about using eval:perl -le '$_=q(ab cdefg);$x=q($1,);s/(^\w+)/$x/;print;'
but that did not do what I needed which is an output of: ab, cdefgperl -le '$_=q(ab cdefg);$x=q($1,);s/(^\w+)/eval$x/e;print;'
it worked!, but unfortunately puts "" around regular strings. Any suggestions on how I can interpolate $1 inside of a variable with out any side effects similar to qq("")? -tengo mas que aprenderperl -le '$_=q(ab cdefg);$x=q($1,);s/(^\w+)/qq("$x")/ee;print;'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interpolating $1 within a variable
by tachyon (Chancellor) on Oct 27, 2001 at 17:20 UTC | |
|
Re: Interpolating $1 within a variable
by Zaxo (Archbishop) on Oct 27, 2001 at 18:08 UTC | |
|
Re: Interpolating $1 within a variable
by tachyon (Chancellor) on Oct 27, 2001 at 17:11 UTC | |
by s0ttle (Scribe) on Oct 27, 2001 at 17:22 UTC | |
|
Re: Interpolating $1 within a variable
by chromatic (Archbishop) on Oct 28, 2001 at 02:16 UTC | |
|
Re: Interpolating $1 within a variable
by CharlesClarkson (Curate) on Oct 28, 2001 at 11:21 UTC | |
by s0ttle (Scribe) on Oct 29, 2001 at 14:43 UTC |