http://www.perlmonks.org?node_id=504076


in reply to splitting up a long text at regular intervals

I'm not sure as to what exactly your asking, but allow me to point you into the direction of unless ($. % 15) {}


Evan Carroll
www.EvanCarroll.com

Replies are listed 'Best First'.
Re^2: splitting up a long text at regular intervals
by pg (Canon) on Oct 30, 2005 at 23:43 UTC

    $. is error prone, as one can have multiple files open in a program, but there is only one $. I would rather call input_line_number() with specific file handler.

    use IO::Handle; open(MYSELF1, "<", "test.pl"); open(MYSELF2, "<", "test.pl"); while (<MYSELF1>) { print "after reading from myself1: $.\n"; if ($. % 2) { <MYSELF2>; print "after reading from myself2: $.\n"; } print "returned values from input_line_number: ("; print MYSELF1->input_line_number(), ", "; print MYSELF2->input_line_number(), ")\n"; } close(MYSELF1); close(MYSELF2);