in reply to Re: using a variable as a filehandle
in thread using a variable as a filehandle

what is wrong with this: I am running perl 5.8.1.
open (RF,"<:raw:scalar", $$record{data}) or die "Couldn't open memory + file: $!"; while(my $line = <RF>){ print "\n in while \n"; } close(RF);
It doesn't die. (i verified there is data in the variable) and it never prints "in while" so it appears <> is finding no lines. any ideas thanks again

Thanks! Its cool you can read from memory like filehandle (learn something enw everyday!!!) Once i get it to work i will be thrilled!!

Replies are listed 'Best First'.
Re^3: using a variable as a filehandle
by diotalevi (Canon) on Nov 01, 2004 at 19:09 UTC

    You might try changing the :raw to :crlf. Try also setting $/ to \n.

    open my $fh, "<:crlf:scalar", $record{'data'} or die ...; { local $/ = "\n"; while ( my $line = <$fh> ) { print "in line\n"; } }