PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:
Good Afternoon oh wise Monks I do have a question and the code is posted below
sub railcarcount { my %count; Title "Total Railcar Count"; open(INPUT, "<railcardata.txt"); open(OUTPUT, ">railcarcountdata.txt"); my $railcarcnt='Boxcar|Reefer|Flatcar|Tankcar|Gondola|Hopper'; while(<INPUT>){ my @words = split(/\:/); foreach my $word (@words){ if($word=~/($railcarcnt)/io){ $count{$1}++; } } } print colored ("------------------------------------------------------ +--------------------------",'green bold'); print colored (" TOTAL RAILCARS LISTED BELOW + ",'green bold'); print colored ("------------------------------------------------------ +--------------------------\n\n\n\n",'green bold'); foreach my $word (sort keys %count) { printf("%42s %-16s %-23s %6s", colored("There are",'cyan bold'), colored("$count{$word}",'yellow bold'), colored("$word",'cyan bold'), colored("Car(s)\n",'cyan bold') ); print OUTPUT "There are $count{$word} $word Car(s)\n"; } close INPUT; close OUTPUT; print colored ("\n\n\n\n\n WHEN YOU ARE DONE VIEWING + HIT RETURN TWICE:\n\n\n", 'green bold'); my $input = <STDIN>; $input = <STDIN> until defined $input; chomp($input=<STDIN>); cls(); structure::railcar(); }
__DAT__
B&LE:65065:Hopper:Home
B&LE:65700:Hopper:Home
VM:51142:Hopper:Home
OS:1400:Hopper:Home
__OUTPUT__
There are 16 Car(s)
There are 4 Hopper Car(s)
What I "think" it is doing is counting all the words and giving a total up top....that output is not relevant...only the car count. How do I remove that part? Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Remove a Line
by CountZero (Bishop) on Apr 01, 2013 at 09:24 UTC | |
by PilotinControl (Pilgrim) on Apr 01, 2013 at 13:58 UTC | |
Re: Remove a Line
by CountZero (Bishop) on Mar 31, 2013 at 21:00 UTC | |
by PilotinControl (Pilgrim) on Mar 31, 2013 at 22:00 UTC | |
by CountZero (Bishop) on Apr 01, 2013 at 08:59 UTC | |
by Anonymous Monk on Mar 31, 2013 at 22:42 UTC | |
by PilotinControl (Pilgrim) on Apr 01, 2013 at 00:14 UTC | |
by Anonymous Monk on Apr 01, 2013 at 02:14 UTC | |
Re: Remove a Line
by poj (Abbot) on Apr 01, 2013 at 08:44 UTC |