Just to be a little more clear about what is happening here:

Perl 5 tended to treat things as strings if you use them as strings, or as
numbers if you use them as numbers. Perl 6 is more strict about that, but
makes an exception for specifically numbers and strings; if you have
noticed the class "Cool", that's a class whose subclasses are string and
number classes, and which tries to make one into the other if needed.

Subs aren't Cool. [ :) ] They are objects of type Sub, which is *not* a
String (nor has a Stringy role, nor is a subclass of Cool). Perl 6 wants
you to explicitly make a string in this case; and as there are multiple
strings one could want (the name? a summary of the definition like .gist
makes? the full definition like .perl is intended to make but IIRC doesn't
yet? something else?) you need to specify exactly *what* string to get from
a Sub object.

On Tue, Mar 14, 2017 at 1:00 AM, ToddAndMargo <toddandma...@zoho.com> wrote:

> On 03/13/2017 09:16 PM, ToddAndMargo wrote:
>
>> What am I doing wrong now !?!?!  :'(  :'(  :'(
>>
>> <code>
>> #!/usr/bin/perl6
>>
>> sub Test () {
>>
>>    my $f = $?FILE; say "\$\?FILE=<$f>";
>>    my $g = $?FILE.IO.basename;  say "\$\?FILE.IO.basename=<$g>";
>>    ( my $IAm = $?FILE ) ~~ s|.*"/"||; say "Regex \$IAm=<$IAm>";
>>
>>
>>    # sub Test () { #`(Sub|58588296) ... }
>>    my $h = &?ROUTINE;
>>    say "\&\?ROUTINE=<$h>\n";
>>    $h ~~ m/' '(.*?)' '\(/;
>>    say "This sub\'s name is <$0>";
>> }
>>
>>
>> Test();
>> </code>
>>
>>
>> $ WhoTest.pl6
>> $?FILE=</home/linuxutil/./WhoTest.pl6>
>> $?FILE.IO.basename=<WhoTest.pl6>
>> Regex $IAm=<WhoTest.pl6>
>> Sub object coerced to string (please use .gist or .perl to do that)
>>   in sub Test at ./WhoTest.pl6 line 12
>> &?ROUTINE=<Test>
>>
>> No such method 'match' for invocant of type 'Sub'
>>   in sub Test at ./WhoTest.pl6 line 13
>>   in block <unit> at ./WhoTest.pl6 line 18
>>
>>
>> &?ROUTINE
>>
>>
>>
>>
>
> Figured it out with the help of the chat line.  I
> need to add .gist onto &?ROUTINE so that regex sees
> a string
>
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>



-- 
brandon s allbery kf8nh                               sine nomine associates
allber...@gmail.com                                  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

Reply via email to