in reply to Re: Buffered IO and un-intended slurping
in thread Buffered IO and un-intended slurping

My first thought was "how do I seek() on a scalar?" Buy you mention "opened that scalar as a ram-file" which seems to imply there is a way to do just that
How about a pointer to the method?

It is always better to have seen your target for yourself, rather than depend upon someone else's description.

  • Comment on Re^2: Buffered IO and un-intended slurping

Replies are listed 'Best First'.
Re^3: Buffered IO and un-intended slurping
by BrowserUk (Patriarch) on Jan 02, 2010 at 14:55 UTC

    See open for details:

    open my $fhFile, '<', 'theFile' or die $!; my $slurpedFile; { local $/; $slurpedFile = <$fhFile>; } close $fhFile; ## Supplying a reference to a scalar as the filename ## initiates the opening of a ram file. open my $fhRam, '<', \$slurpedFile or die $!; ## Now file operations on $fhRam will read from the slurped scalar my $firstLine = <$fhRam>; ...

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.