Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cog (4665)

Journal of cog (4665)

Friday April 30, 2004
11:44 AM

$/ to read 100 lines at a time

[ #18563 ]

If I wanted to read X lines at a time (say 100), how should I do that using $/ ?

Some regex with a look behind to find 100 \n's would do the trick, probably... but isn't there an easier way? :-|

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • From perlvar:
    Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)

  • Using Inline::C, of course! :)
  • Instead of something complicated, just write a routine that reads the right number of lines and returns them.
    my @lines = read_lines( $fh, 100 );
    That routine can be as simple as a for() loop. Once you code those five or six lines, relax, put your feet up on the table, and get on with life. :)