Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 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 (Bishop) 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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2015-05-28 09:15 GMT
Find Nodes?
    Voting Booth?

    In my home, the TV remote control is ...

    Results (550 votes), past polls