gopikavi has asked for the wisdom of the Perl Monks concerning the following question:
My code:{asf192lin1 C 0/8 0 0 0 4503 16 2922 44316 1} {asf256lin10 + 2/16 15 0 0 4641 16 2926 194108 0} {cad192lin1 C 0/12 2 0 0 1432 12 3397 179605 0} {cas256lin1 C 0/12 50 0 56 3992 12 3397 165099 0} {cas192lin11 C 0/12 50 0 56 3992 12 3397 165099 0} {dsf192lin6 + 0/16 0 0 0 4751 16 2930 179123 0}
My query:open my $f,"<gen_machines_data.txt" or die $!; my($slots_used,$slots_free); while(<$f>) { #print $_; $slots_used += (split(/\s+/,$_))[3]; $slots_free++; } close $f; print "total slots used:$slots_used\n"; print "total slots free:$slots_free\n";
But the above code gives me wrong output.Kindly help me to revamp my perl script as per my requirements.open my $f,"<gen_machines_data.txt" or die $!; my($slots_used,$slots_free); while(<$f>) { #print $_; $slots_used += (split(/\s+/,$_))[3]; $slots_free++; } close $f; print "total slots used:$slots_used\n"; print "total slots free:$slots_free\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to add the rows by its similar row names using perl?
by huck (Prior) on May 05, 2017 at 05:46 UTC | |
Re: How to add the rows by its similar row names using perl?
by kcott (Archbishop) on May 05, 2017 at 07:42 UTC |