Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RobPayne's scratchpad

by RobPayne (Chaplain)
on Mar 07, 2006 at 02:09 UTC ( #534809=scratchpad: print w/ replies, xml ) Need Help??

looping exercises

The following command line prints the first 560 numbers, one per line. I used it to test the second script.

perl -e 'for ($i = 1; $i <= 560; $i ++) {print "$i\n";}'

A little script to print every nth line, where n is currently 56.

#!/usr/bin/perl -w use strict; my($line) = ""; my($counter) = 0; # print every nth line of STDIN, where n is defined as: my($countTo) = 56; while ($line = <STDIN>) { $counter += 1; if($counter == $countTo) { print $line; $counter = 0; } }

Now a little different, a short script to remove the first eight lines of each 56-line page.

#!/usr/bin/perl -w use strict; # # script to remove the first eight lines after lines of a page 56 # lines long. # my($line) = ""; my($counter) = 0; my ($boolean) = 0; # print every nth line of STDIN, where n is defined as: my($countTo) = 56; my($secondCounter) = 8; while ($line = <STDIN>) { $counter += 1; if($counter > $secondCounter) { print $line; } if($counter == $countTo) { $counter = 0; } }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-12-19 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls