On 09/14/2006 01:18 AM, Xavier Mas i Ramón wrote:
Hi all!,

I'm trying to create a sorted (ASCII) hash file but get all time a syntax error in line "my $abreviatures{$clau} = 1;" at "$abreviatures{ <--". Sure is an stupid mistake but I'm not able to see it even checking with my "Learning Perl" book.

Pls, can someone tell me where is the syntax error?

...
while (<ABREVIATURES>) {
chomp;
my $clau = $_;
my $abreviatures{$clau} = 1;
}
close ABREVIATURES;
...

Many thanks,


The "my" command doesn't work that way. You have to "my" the entire hash like so:

...
my $abreviatures;
while (<ABREVIATURES>) {
  chomp $_;
  my $clau = $_;
  $abreviatures{$clau} = 1;
}
close ABREVIATURES;
...


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to