in reply to Re: pointing a filehandle at a scalar or array ?
in thread pointing a filehandle at a scalar or array ?
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; }
|
|---|