in reply to Re: Write to and read from scalar
in thread Write to and read from scalar

GrandFather,

I did it this way from your example. I would not have known how to do this, but the disk file is basically a representation of the scalar.

my $str = "Hello World\n"; open my $fIn, '<', \$str; my $inStr = <$fIn>; close $fIn; print $inStr;

Is there a reason to use file I/O to the scalar?

Thank you

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re^3: Write to and read from scalar
by GrandFather (Saint) on Mar 23, 2012 at 22:56 UTC

    For one use reread the OP's node. I frequently use the technique when answering SoPW's where an input file is required. I could write a temporary file then use that, but that adds clutter to the sample.

    In real applications I've used the technique to cache parts of a file that I need to access frequently and to provide a file handle for modules that require them when I really want to pass in a string.

    True laziness is hard work