lightoverhead has asked for the wisdom of the Perl Monks concerning the following question:
it report the error: "Use of uninitialized value in addition (+) at dup.pl line 6.." If I change that line code to "$dup{$row3}++", then it's all right. Who can tell me why this happened? Thanks.1 #!/usr/bin/perl -w 2 use strict; 3 my %dup; 4 while(<>){ 5 my @row=split(/\s+/,$_); 6 $dup{$row[3]}=$dup{$row[3]}+1; #if change to $dup{$row[3]}++, it w +ill run smoothly no error report 7 } 8 9 foreach my $id (keys %dup){ 10 if ($dup{$id}>1) { 11 print "$id\t$dup{$id}\n"; 12 } 13 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why such an error?
by FunkyMonk (Bishop) on Sep 25, 2008 at 19:07 UTC | |
by lightoverhead (Pilgrim) on Sep 25, 2008 at 20:30 UTC | |
by GrandFather (Saint) on Sep 25, 2008 at 23:24 UTC | |
by rovf (Priest) on Sep 26, 2008 at 08:59 UTC |