in reply to Clash between IO layers and "in memory" files?

Similar behavior when you try to auto-open a string ref via @ARGV
my $header_line = "Prepend this\n"; unshift @ARGV, \ $header_line; print while <>;
results in
Can't open SCALAR(0x816411c): No such file or directory at ...
Anno

Replies are listed 'Best First'.
Re^2: Clash between IO layers and "in memory" files?
by blazar (Canon) on Mar 29, 2007 at 12:38 UTC
    Similar behavior when you try to auto-open a string ref via @ARGV

    Well, I had never thought of that and never seen it documented, although it would certainly be useful a feature to have. But it is somewhat annoying that e.g. '<' works and '<:raw' doesn't. perldoc -f open, now that I notice, only says:

    Since v5.8.0, perl has built using PerlIO by default. Unless you've changed this (i.e. Configure -Uuseperlio), you can open file handles to "in memory" files held in Perl scalars via: open($fh, '>', \$variable) || ..

    There's another example later (and no other ones) again with '>', but the technique also works in read mode and, now that I check, with '+>' and '+<'. OTOH it is not entirely clear if the above text is to mean that "in memory" files should be provided only in write mode or whenever the third argument is a scalar reference...