Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: How to read every 16 line of file ?

by Anonymous Monk
on May 13, 2011 at 03:42 UTC ( [id://904584]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to read every 16 line of file ?
in thread How to read every 16 line of file ?

FWIW, if reading from STDIN, there are no file boundaries :)
  • Comment on Re^3: How to read every 16 line of file ?

Replies are listed 'Best First'.
Re^4: How to read every 16 line of file ?
by ikegami (Patriarch) on May 13, 2011 at 06:28 UTC

    My code reads from ARGV, not STDIN, so his comment does apply. Mind you, the OP said "file" singular, so resetting shouldn't be necessary.

    See eof to reset the counter between files when using ARGV.

Re^4: How to read every 16 line of file ?
by bh_perl (Monk) on May 13, 2011 at 04:04 UTC

    This is my sample code to be execute but this is sample only..
    #!/usr/bin/perl -w open (FILE, "/tmp/test.txt"); while ($line = <FILE>) { ... READ EVERY 16 LINE... } close(FILE);
      You can't "read every 16th line", you can "do something with every 16th line", and I showed how already. Just replace "say" with whatever you want to do to the selected lines.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904584]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-18 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found