Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Interpolating $1 within a variable

by CharlesClarkson (Curate)
on Oct 28, 2001 at 11:21 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://121803]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found