Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Need Perl6: Inline::Perl5 help

by duelafn (Parson)
on Mar 05, 2017 at 15:36 UTC ( #1183701=note: print w/replies, xml ) Need Help??

in reply to Need Perl6: Inline::Perl5 help

This works:

#!/usr/bin/perl6 use Inline::Perl5; use Term::ANSIColor:from<Perl5> <color RED RESET>; my $Red = color("red"); my $Reset = color("reset"); say $Red ~ "--Red--" ~ $Reset; say RED ~ "--Red--" ~ RESET; say "{RED}--Red--{RESET}"; # And Laurent_R is right: my $Blue = Term::ANSIColor::color("blue"); say $Blue ~ "--Blue--" ~ $Reset;

Update: Another approach which works:

my $p5 =; $p5.use('Term::ANSIColor'); my $Green = $'Term::ANSIColor::GREEN'); say $Green ~ "--Green--" ~ $Reset;

However, this doesn't work (was trying to get around the AUTOLOAD):

Term::ANSIColor.YELLOW; # AUTOLOAD should generate YELLOW my $Yellow = Term::ANSIColor::YELLOW; # Hmm, nope :( at least not v +isible to Perl6 say $Yellow ~ "--Yellow--" ~ $Reset;

Good Day,

Replies are listed 'Best First'.
Re^2: Need Perl6: Inline::Perl5 help
by Todd Chester (Scribe) on Mar 06, 2017 at 07:22 UTC
    Thank you all for the help and tips!


    This is my notes on Inline::Perl5. I hope this is useful to others.


    #!/usr/bin/perl6 # Inline::Perl5 test # Reference: +19db8cfbb551f7a87ef79bdc2a8b use Inline::Perl5; use Term::ANSIColor:from<Perl5>; # my $Red = Term::ANSIColor.RED; # my $Reset = Term::ANSIColor.RESET; my $Red = color('red'); my $Reset = color('reset'); print "High Level method:\n"; print $Red ~ "--Red--" ~ $Reset ~ "\n\n"; print "Low Level method:\n"; my $P5Color =; $P5Color.use( 'Term::ANSIColor' ); my $ResetColor = "RESET"; print ( $ 'Term::ANSIColor::GREEN' ) ~ "Red\n" ~ $ "Term::ANSIColor::$ResetColor" ) ~ "\n" ); my $p6str = "Perl 6 String"; my $perl5colors =; ${ use Term::ANSIColor qw [ BLUE RESET ]; print "p5 term with color\n" . BLUE . "I am blue\n" . "$p6str" . RESET . "\n\n"; }); print "\'run\' method:\n"; my $perl5 =; $ ' print "Perl 5\' local time is " . localtime . "\n\n"; ' +); print "Test of return values\n"; my $RetStr =; print ${ return ( "P5 return string\n\n" ) });

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1183701]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-12-06 01:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found