syntax errors?
- From: cspears2002@xxxxxxxxx (Christopher Spears)
- Date: Tue, 28 Mar 2006 17:42:54 -0800 (PST)
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?
.
- Follow-Ups:
- Re: syntax errors?
- From: Mr. Shawn H. Corey
- Re: syntax errors?
- From: Tom Phoenix
- Re: syntax errors?
- Prev by Date: Re: 'print q^ndzk+^^q?$%*#!?;'
- Next by Date: Re: syntax errors?
- Previous by thread: Please disregard AS does have it in PPM: Looking for the module Algorithm-Combinatorics
- Next by thread: Re: syntax errors?
- Index(es):
Relevant Pages
|
|