Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Interpolating $1 within a variable

by CharlesClarkson (Curate)
on Oct 28, 2001 at 11:21 UTC ( #121803=note: print w/replies, xml ) Need Help??

in reply to Interpolating $1 within a variable

Er, I'm confused:
$_ = q(ab cdefg); $x = q($1,); s/(^\w+)/qq("$x")/ee; print;
ab, cdefg

What do you mean by: 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("")? What side effects?

Charles K. Clarkson

Replies are listed 'Best First'.
Re: Interpolating $1 within a variable
by s0ttle (Scribe) on Oct 29, 2001 at 14:43 UTC
    What I meant was that when $x=q(ab,); the output was: "ab," cdefg
    but I found out why it was doing this. I had forgotten to add the extra /e and so I kept running:
    perl -le '$_=q(ab cdefg);$x=q(ab,);s/(^\w+)/qq("$x")/e;print;'
    But the problem is fixed now. Thank you monks.

    -tengo mas que aprender

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://121803]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2016-10-26 10:31 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.