PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:
The elsif statement repeats the output and I am not sure why
sub viewrailcarsroadname{ no warnings 'redefine'; no warnings 'uninitialized'; print color 'green'; open(MYINPUTFILE, "railcardata.txt"); # open for input $| = 1; my @lines = <MYINPUTFILE>; # read file into list close (MYINPUTFILE); printf (" ===============================\n\n" +); printf (" | VERIFY CAR ROAD NAME |\n\n" +); printf (" ===============================\n\n" +); printf (" \n\n" +); printf (" PLEASE INSERT ROADNAME TO VERIFY:\n\n +"); printf (" \n\n\n\n\n\n\n\n"); my $carroadnameverify = <STDIN>; chomp($carroadnameverify); printf ("\n ================================================== +=================\n\n"); printf (" | ROAD NAME | ROAD NUMBER | CAR TYPE | INTERCH +ANGE RAILROAD |\n\n"); printf (" ==================================================== +===============\n\n\n"); foreach my $carroadnameverify2 (@lines) { if ($carroadnameverify2 =~ /$carroadnameverify/) { my $format = " %-13s %-15s %-12s %0s"; printf ("$format", split/\:/, "$carroadnameverify2"); } elsif ($carroadnameverify2 =~ '') { printf ("CAR RECORD NOT FOUND"); } } # END FILE LOOP printf ("\n\n\n\n WHEN YOU ARE DONE VIEWING HIT RE +TURN TWICE:\n\n\n\n\n\n\n\n"); my $input = <STDIN>; chomp($input=<STDIN>); structure::railcar(); } # END VIEW SUB
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Output Repeats in the elsif statement
by jwkrahn (Abbot) on Feb 13, 2013 at 21:56 UTC | |
Re: Output Repeats in the elsif statement
by Kenosis (Priest) on Feb 13, 2013 at 21:08 UTC | |
by PilotinControl (Pilgrim) on Feb 13, 2013 at 21:19 UTC | |
by Kenosis (Priest) on Feb 13, 2013 at 22:04 UTC | |
by PilotinControl (Pilgrim) on Feb 14, 2013 at 02:28 UTC | |
by Athanasius (Archbishop) on Feb 14, 2013 at 03:12 UTC | |
by Kenosis (Priest) on Feb 14, 2013 at 03:13 UTC | |
Re: Output Repeats in the elsif statement
by nvivek (Vicar) on Feb 14, 2013 at 05:23 UTC | |
by PilotinControl (Pilgrim) on Feb 14, 2013 at 12:45 UTC |
Back to
Seekers of Perl Wisdom