Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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)\"}

Replies are listed 'Best First'.
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)"}/;
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 mouser13 (Novice) on Nov 01, 2012 at 18:34 UTC
    oops I somehow removed the varible assignment I had $ sign. Sorry

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001858]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-04-23 09:19 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (430 votes). Check out past polls.