develooper Front page | perl.perl6.users | Postings from October 2018

Re: Appropriate last words

Thread Previous | Thread Next
From:
Brian Duggan
Date:
October 26, 2018 01:34
Subject:
Re: Appropriate last words
Message ID:
20181026013403.GA16415@localhost
On Thursday, October 25, Brandon Allbery wrote: 
> You can't actually wrap print that way, can you? Or rather, if that works
> it wouldn't be specific to $*ERR.

Um, you definitely can, and yes it's not specific to $*ERR, e.g.

    my @lines;
    $*OUT.^find_method('print').wrap: -> $self, $str { @lines.push($str) }

    use Test;
    say "hello";
    is @lines[0], "hello\n", 'said hello';

produces

    ok 1 - said hello

Brian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About