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

Re: Reading files n lines a time

by blue_cowdawg (Monsignor)
on Dec 06, 2012 at 14:50 UTC ( #1007591=note: print w/replies, xml ) Need Help??


in reply to Reading files n lines a time

Consider this solution:

#!/usr/bin/perl -w ###################################################################### +## use strict; use Tie::File; tie my @fin,"Tie::File","multilines.txt" or die $!; for(my $ix=0;$ix <= $#fin;$ix+=4){ my @lines=(); foreach (my $iy=0;($iy < 4) && (($ix+$iy)<=$#fin);$iy++){ push @lines, $fin[$ix+$iy]; } printf "Lines starting with line %d:\n%s\n\n",$ix+1,join("\n",@lin +es); } untie @fin;
Tie::File lets you play with files as if they were arrays and is part of the standard Perl distribution.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: Reading files n lines a time
by Kenosis (Priest) on Dec 06, 2012 at 17:19 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007591]
help
Chatterbox?
[hippo]: Is the NVIDIA driver problem still a thing?
[zentara]: See problems with Nvidia and Linus Torvalds
[choroba]: that's 2012
[zentara]: I just acquired a computer with the card type, and wondered if it was best to stick with the open-source code or use NVIDIA's proprietary code
[zentara]: do you feel good about a non-open-source code, being in control of your display functions?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-05-26 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?