syntax errors?



I'm trying to solve a problem in Intermediate Perl.
Basically, I open a text file and read its
information. Here is some text from the file:

gilligan.crew.hut lovey.howell.hut 4721
thurston.howell.hut lovey.howell.hut 4046
professor.hut ginger.girl.hut 5768
gilligan.crew.hut laser3.copyroom.hut 9352
gilligan.crew.hut maryann.girl.hut 1180

Basically, the text shows the source of a data
transfer, the destination of that transfer, and the
number of byte's transferred.

Then I modify some code from the book to create a
printout that shows each source machine's total
output.

#!/usr/bin/perl -w
use strict;

my %total_bytes;
while (<>) {
unless (/^#/) {
my ($source, $destination, $bytes) = split;
$total_bytes{$source}{$destination} +=
$bytes;
}
}

my %sum;
for my $source(keys %total_bytes) {
for my $destination ( keys %{ $total_bytes{$source}
}) {
my $sum{$source} += my
$total_bytes{$source}{$destination};
}
}

I think my logic is solid, but I keep getting error
messages:

syntax error at ./sourceOutput.pl line 15, near
"$sum{"
syntax error at ./sourceOutput.pl line 15, near "+="
syntax error at ./sourceOutput.pl line 16, near "}"
Execution of ./sourceOutput.pl aborted due to
compilation errors.

Am I missing something?
.



Relevant Pages

  • CGI: Premature end of script headers
    ... I've installed AM Lite on an HP-UX 11.0 system running Apache 2 with PERL ... If you think this is a server error, ... syntax error in file amadmin.pl at line 224, next 2 tokens "@file)" ... syntax error in file amadmin.pl at line 241, ...
    (perl.beginners)
  • Re: error when accessing hash of arrays
    ... I am a perl newbie and have a problem which can be reduced to the ... I have a hash-reference of a hash, which values are references to ... is used to index into either an array or a list. ... In my perl, I get the below syntax error first, then the above "requires ...
    (comp.lang.perl.misc)
  • RE: garbage errors when number of characters in script exceeds some number
    ... Please group reply so others can help and be helped, and so your posts ... which may be found in the Perl 5 source kit. ... I am wondering if this is a line ending problem, was the script ever ... This is not a garbage error, you have a syntax error. ...
    (perl.beginners)
  • Image-Imlib2 "build-problem" edit includepath ? (2)
    ... Just found out that this forum seems more ... I've fetched the latest version of Image-Imlib2 and when I run "perl ... Imlib2.xs:12: syntax error before `Image__Imlib2' ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Kalender programm
    ... "Christoph Sünderhauf" wrote in message ... If perl tells you there's a syntax error, ... And declare them when you need them, ...
    (comp.lang.perl.misc)