[comp.lang.perl] filehandle in local variable?

guy@b11.ingr.com (Guy Streeter) (03/05/91)

The following code illustrates a problem I'm having:
----------------------------------------------------------------
open (tome,">/usr/tmp/testing") || die "screwed up\n";

open (frim,"</etc/passwd") || die "hosed down\n";

do doit ();

close tome;
close frim;

sub doit {
    local($ltome) = "tome";

    print ($ltome "this is it:\n") || die "before the loop\n";

    while (<frim>) {
	print ($ltome $_) || die "in the loop\n";
    }

    print ($ltome "that was it.\n") || die "after the loop\n";
}
----------------------------------------------------------------
This code always fails on the last "print" in the subroutine, but only
if the filehandle is referenced through the local variable.  Is there
some reason for this, or is it a bug?

thanks,
Guy Streeter
streeter@ingr.com

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (03/06/91)

In article <guy.668122029@guy> guy@b11.ingr.com (Guy Streeter) writes:
: The following code illustrates a problem I'm having:
[deleted]
: This code always fails on the last "print" in the subroutine, but only
: if the filehandle is referenced through the local variable.  Is there
: some reason for this, or is it a bug?

It works fine here.

You didn't say what kind of machinery or OS you're using.  You didn't
say which version and patchlevel of perl you're using.  It's difficult
to help without this information.  This looks vaguely like a problem that
was fixed some time ago.

Larry