in reply to Sending filehandles?
use strict; package Foo; sub line { my $fh = shift; return <$fh>; } package main; open FH, $file; # depending on the perl version, use 3 argument open my $line = Foo::line(*FH);
update: that said, passing around a file handle is icky. You should reconsider your layout and encapsulate file operations into functions or methods. Make those callable from elsewhere, probably via an object.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sending filehandles?
by chromatic (Archbishop) on Feb 08, 2008 at 21:20 UTC | |
by shmem (Chancellor) on Feb 08, 2008 at 22:16 UTC | |
|
Re^2: Sending filehandles? (\*)
by tye (Sage) on Feb 09, 2008 at 08:19 UTC |