2009/10/9 Soham Das <sohamdas@yahoo.co.in>:
When I compile this, it gives me an error like this:

Can't modify constant item in scalar assignment at Test.pl line 18, near "}";

So for the sake of clarity I highlited the Line 18.


A bit of help in this, will be great!
When perl gives you a line number, it's usually best to check the
whole statement for errors, not just the line that it gives you; in
this case the statement (from $dailytrade to the next semicolon ; ) is
six lines long.

The error message tells you that you can't modify a constant. It also
mentions an assignment. Here's the full statement:
'Scrip'= $trades->{'Scrip'},
'Shares'= $trades->{'Shares'},
Looking at line 18 again:
Aha! You have an assignment (an = sign) which is trying to assign to
'Action', a string constant. The error message was right! The solution
is that you should have used a fat comma (a => sign) instead:
This is the syntax used to create hash initialisers. If this confuses
you, I suggest you read perldoc perldata, section "List value
constructors". (If this confuses you too, then we need to have a chat
about perldoc :) )

Going back to the original statement:
'Scrip'= $trades->{'Scrip'},
'Shares'= $trades->{'Shares'},
You've made the same mistake in lines 19, 20 and 21. You should now be
able to fix your code.


Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 10 | next ›
Discussion Overview
groupbeginners @
postedOct 9, '09 at 5:14a
activeOct 9, '09 at 12:09p



site design / logo © 2021 Grokbase