Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to recast $*ARGFILES

Tags:

io

raku

In order to fix this error I would need to re-cast $*ARGFILES as a IO::CatHandle, since it uses some attributes of that class. I'm trying this:

use IO::CatHandle::AutoLines; # -*- mode:perl6 -*-
use Test;

if $*ARGFILES === $*IN {
    $*ARGFILES = IO::CatHandle.new( $*IN );
}
eval-lives-ok "$*ARGFILES does IO::CatHandle::AutoLines", "Can recast \$*ARGFILES";

But this yields the error:

# Error: Unsupported use of <STDIN>; in Perl 6 please use $*IN.lines (or add whitespace to suppress warning)

This is independent, I think, of the role I'm mixing, but I add it for context. Any idea of what else could be done?

like image 855
jjmerelo Avatar asked Mar 13 '20 12:03

jjmerelo


1 Answers

The error you see is very LTA, but a side-effect of using double quotes, when you should have been using single quotes:

eval-lives-ok '$*ARGFILES does IO::CatHandle::AutoLines',
  "Can recast \$*ARGFILES";
# ok 1 - Can recast $*ARGFILES

So you're trying to stringify $*ARGFILES, which yields the string:

<STDIN> does IO::CatHandle::AutoLines

and that does not EVAL very well :-)

like image 77
Elizabeth Mattijsen Avatar answered Nov 04 '22 16:11

Elizabeth Mattijsen