in reply to Can a string be a file hanle?

Yes it can, have a look at perldoc -f open:
sub subroutine { my $fh = shift; print $fh "Hello, filehandle!\n"; } my $dest; open my $fh, '>', \$dest; subroutine($fh); close $fh; print "\$dest is '$dest'";
Cheers,
CombatSquirrel.

Entropy is the tendency of everything going to hell.

Replies are listed 'Best First'.
Re^2: Can a string be a file hanle?
by JediWizard (Deacon) on Sep 26, 2004 at 23:14 UTC

    That is a cool trick. I looked in opentut and open and didn't see any indication that such a thing was possible. Where did you find out you could do this?

    May the Force be with you
      If you look about a third of the way down on the "open" man page that you linked to in your own reply, you'll find the part that describes how 'File handles can be opened to "in memory" files held in Perl scalars...'

      Stringstreams were introduced somewhere near perl 5.8. Check if you have a new enough perl. If you didn't see this in perlfunc or perlopentut, you might have a too old version.

        That is the problem. I was looking at the docs for Perl 5.6.1. I also have 5.8.0 installed on my machine, and looking at the docs for that, I do see the Stringstreams mentioned.

        Thank you ambrus.

        May the Force be with you