I think, the way you went about solving the problem {might be very trivial for you}, but laying bare your entire thought process, just taught something to me.

Thanks and I am sure, many other beginners have picked it up from here.

Yes,indeed after you pointed out to me, I (figuratively) kicked myself.



From: Philip Potter <philip.g.potter@gmail.com>
To: Soham Das <sohamdas@yahoo.co.in>
Cc: beginners@perl.org
Sent: Fri, 9 October, 2009 2:22:49 PM
Subject: Re: Building a record on the fly via hash of hashes

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.


To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

From cricket scores to your friends. Try the Yahoo! India Homepage! http://in.yahoo.com/trynew

Search Discussions

Discussion Posts


Follow ups

Related Discussions

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



site design / logo © 2021 Grokbase