angle operator behavior with filehandles in @_
From: John Bullock (john.bullock_at_stanford.edu)
Date: 08/29/04
- Next message: Leif Wessman: "The best way to parse a date in a known format"
- Previous message: ctcgag_at_hotmail.com: "Re: pass 2d array to C function"
- Next in thread: Gunnar Hjalmarsson: "Re: angle operator behavior with filehandles in @_"
- Reply: Gunnar Hjalmarsson: "Re: angle operator behavior with filehandles in @_"
- Reply: Joe Smith: "Re: angle operator behavior with filehandles in @_"
- Reply: Ilmari Karonen: "Re: angle operator behavior with filehandles in @_"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 Aug 2004 22:35:56 -0700
Hello,
I am puzzled by the behavior of the angle
operator (<>) when it operates on a filehandle
that is passed to a subroutine.
Given filehandle FH, these lines are equivalent:
my $tst1 = <FH>;
my $tst1 = readline(FH);
But if I set up a subroutine, there is an oddity:
do_something(*FH);
sub do_something {
my $tst1;
$tst = $readline($_[0]); # works
$tst1 = <$_[0]>; # doesn't work
$tst1 = < {$_[0]} >; # doesn't work
}
Of course, I can get around this by storing the filehandle
in a scalar that I define in the subroutine. But I want to
understand why neither of the last two lines here works
as intended. (They just leave $tst1 undefined, provided
that it hasn't already been defined.) I've looked to what
I thought were the salient parts of the camel book, but I
had no luck. Can you enlighten me or point me to some
relevant reading?
Thanks,
--John
- Next message: Leif Wessman: "The best way to parse a date in a known format"
- Previous message: ctcgag_at_hotmail.com: "Re: pass 2d array to C function"
- Next in thread: Gunnar Hjalmarsson: "Re: angle operator behavior with filehandles in @_"
- Reply: Gunnar Hjalmarsson: "Re: angle operator behavior with filehandles in @_"
- Reply: Joe Smith: "Re: angle operator behavior with filehandles in @_"
- Reply: Ilmari Karonen: "Re: angle operator behavior with filehandles in @_"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|