Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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;
produced:
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://121803]
help
Chatterbox?
LanX last weekend or the one before (???)
choroba needs more questions to provide answers to
jedikaiti looked at last hour of CB, saw "boos" but read "boobs"
[Discipulus]: 2 weekends ago LanX
[Lotus1]: cb is nsfw this morning

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2017-09-20 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (237 votes). Check out past polls.

    Notices?