in reply to Re: Adding Pages
in thread Adding Pages

That would mean I would have to rewrite quite a few subroutines. Something more along the lines of display first ten lines of the file, then the second ten lines and so on by using the enter/return key or any other keystroke for that matter...keeping the same header and footer and so on. I'm on the right track I think.

Replies are listed 'Best First'.
Re^3: Adding Pages
by choroba (Cardinal) on Mar 20, 2014 at 10:11 UTC
    You are not reading from a file, so $. does not change. Either read from the input when printing the lines, or use an index to the array instead.

    Here's how I modified your code:

    #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use v5.10; sub view_all_railcars { say "View All Cars"; *MYINPUTFILE = *DATA{IO}; # To simulate the input. my $viewlines = 4; print "=====================\n"; print "|CAR MODEL|CAR OWNER|\n"; print "=====================\n"; while (<MYINPUTFILE>) { chomp; my ($VcarModel, $VcarOwner) = split /:/; $_ //= q() for $VcarModel, $VcarOwner; if ($. > 1 and $. % $viewlines == 1) { <>; } else { print "\n"; } my $format = " %-13s %0s\n"; printf $format, $VcarModel, $VcarOwner; } print ("\n\n\nWHEN YOU ARE DONE VIEWING HIT RETURN: \n\n\n"); do 1 until defined <>; # Do not end on CTRL+D say 'cls'; say 'Menu'; } view_all_railcars(); __DATA__ Ford|Philip Renault|Renee Citroen|Cyrill Mercedes|Mike Chrysler|Chris Bentley|Brian BMW|Brittney Chevrolet|Shirley Skoda|Stanley
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Hello choroba,
      Thanks for your updated code it does the trick. I'm still a little confused between the 'foreach' and 'while' operations. In my case the 'foreach' statement just displayed the data while the 'while' statement allowed me to manipulate my data. Thanks again.