Wordlover has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl + my $filename ="./multipath.tr"; my @entry; my $size; my $sim_time; my $recv; + $recv = 0; + open(FILE, "<$filename") || die "file $filename can't open : $!"; + while(<FILE>) { print "in while"; @entry = split /\s+/; $size = @entry; print $size; print "\n"; next unless ($size == 51); &get_throughput(@entry); } + sub get_throughput { my $node_id; my $end_point; my $flow_id; my $pkt_id; my $pkt_size; + if($entry[1] == "r") { $sim_time = $entry[3]; $node_id = $entry[5]; $end_point = $entry[39]; $pkt_id = $entry[41]; $pkt_size = $entry[37]; $recv += $pkt_size; } } + + close FILE;> + print $recv; print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What's wrong with my code? [from a beginner]
by holli (Abbot) on Jan 27, 2005 at 19:19 UTC | |
|
Re: What's wrong with my code? [from a beginner]
by Roy Johnson (Monsignor) on Jan 27, 2005 at 19:20 UTC | |
|
Re: What's wrong with my code? [from a beginner]
by punkish (Priest) on Jan 27, 2005 at 20:21 UTC | |
|
Re: What's wrong with my code? [from a beginner]
by bmann (Priest) on Jan 27, 2005 at 20:01 UTC | |
|
Re: What's wrong with my code? [from a beginner]
by 5mi11er (Deacon) on Jan 27, 2005 at 19:18 UTC | |
by holli (Abbot) on Jan 27, 2005 at 19:23 UTC | |
by Roy Johnson (Monsignor) on Jan 27, 2005 at 19:26 UTC | |
by Ardemus (Beadle) on Jan 28, 2005 at 00:23 UTC |