SPUG: FILEHANDLE - What am I missing here.

Sean Dwyer oladar at drizzle.com
Thu Jan 2 23:03:31 CST 2003

    I am trying to use a file handle across several subroutines. In the
code below (which is just a concept test sequence) as it stands when it
hits "sometext" in sub1 I get no more lines printed. If I comment out
sub1 then I dutifully get the first 200 lines of the file, 100 each from
sub2 and sub3. What am I missing here. Why does <FILE> seem to close (or
go out of scope) after sub1. And is there a way to do what I am trying
to do? 
thanks for any help-
use strict;
my ($i, $j);
open FILE, "<somefile.txt";
sub getline{<FILE>;}
sub sub1{
    print "SUB3";
    return if(/sometext/);
sub sub2{
  for($i = 1; $i < 100; $i++){
    my $test = &getline;
    print $test;
sub sub3{
  for($j = 1; $j < 100; $j++){
    my $test = &getline;
    print $test;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20030102/c05e89f3/attachment.htm

More information about the spug-list mailing list