http://www.perlmonks.org?node_id=1026383

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!