in reply to Re: pointing a filehandle at a scalar or array ?
in thread pointing a filehandle at a scalar or array ?

Besides all other answers to this question, I'm desperate to see how this is done. I've blown 10 minutes of my life (so far) trying to figure out how to use Tie::Handle. If I figure it out I'll certainly post it here, but I'd rather that someone else figure it out and tell me. :)

update: I think I got it! That bugged the s**t outta me for 30 minutes. Learn something new every day eh?

#!/usr/bin/perl my $damn_string = "This is so cool...\nThis is less cool.\nThis sucks. +\n"; tie *H, 'str', $damn_string; while(<H>) { print "$_\n"; } package str; use Tie::Handle; my @a; sub TIEHANDLE { my $i = bless \$i, shift; @a = split "\n", shift; return $i; } sub READLINE { return shift @a; }