Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

print help

by mouser13 (Novice)
on Nov 01, 2012 at 18:27 UTC ( #1001858=perlquestion: print w/ replies, xml ) Need Help??
" ;"

mouser13 has asked for the wisdom of the Perl Monks concerning the following question:

I need to print out someing in the format of %CALC{$EVAL(R2:C2 - R1:C2)}%
print "%CALC{\"" . "\$EVAL( R$c:C2 - R$pi:C2)\"}";
I keep getting Can't modify constant item in scalar assignment at CWMSDataPlugin.pm line 76, near ""\$EVAL( R$c:C2 - R$pi:C2)\"}
Comment on print help
Download Code
Re: print help
by mouser13 (Novice) on Nov 01, 2012 at 18:34 UTC
    oops I somehow removed the varible assignment I had $ sign. Sorry
Re: print help
by Riales (Hermit) on Nov 01, 2012 at 18:49 UTC
    print "%CALC{\$EVAL(R${c}:C2 - R${pi}:C2)}%";

    Perl can't divine where your $c and $pi variable names start/end in the string, so you have to wrap them in curly braces.

    Edit: Whoops, the code is right (I think), but the reasoning is wrong. Didn't notice that a colon immediately followed the variable names; that renders what I said before moot.

    Edit2: Ah, toolic has pointed out the real problem already.

Re: print help
by toolic (Chancellor) on Nov 01, 2012 at 18:49 UTC
    I see that you have solved your problem. Additionally, you could use qq to reduce some of that clutter (fewer quotes and backwhacks):
    print qq/%CALC{"\$EVAL( R$c:C2 - R$pi:C2)"}/;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001858]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-07-30 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls