Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 (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?
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 exploiting the Monastery: (11)
As of 2015-07-02 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls