in reply to Remove a Line

OK. I had another look at your program.

I rewrote it and left out all the fancy formatting (which really put me on the wrong track) and brought it down to the bare minimum.

As you will see when you run the program, it works perfectly and the output is as expected:

use Modern::Perl; my %count; my $railcarcnt = qr(Boxcar|Reefer|Flatcar|Tankcar|Gondola|Hopper); while (<DATA>) { $count{$1}++ if /($railcarcnt)/i; } foreach my $word ( sort keys %count ) { say "There are $count{$word} $word Car(s)"; } __DATA__ B&LE:65065:Hopper:Home B&LE:65700:Hopper:Home VM:51142:Hopper:Home OS:1400:Hopper:Home HT&SF:1234:Flatcar:Away NMBS:999:Reefer:Gone
Output:
There are 1 Flatcar Car(s) There are 4 Hopper Car(s) There are 1 Reefer Car(s)
I can only guess that there must be a data issue or that the code you posted is not the code that actually ran to get you that output.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Remove a Line
by PilotinControl (Pilgrim) on Apr 01, 2013 at 13:58 UTC

    I fixed the issue...it was a typo in the code...in the $railcarcnt section I had an extra " | " in the line which threw everything off as the code was looking for additional data which it would of never found or have been inputted..after awhile it all seems to run together....in the middle of the night. Thanks for the input.