develooper Front page | perl.perl5.porters | Postings from May 2016

Re: 5.24.0 + cpan

Thread Previous | Thread Next
From:
Zefram
Date:
May 17, 2016 13:43
Subject:
Re: 5.24.0 + cpan
Message ID:
20160517134300.GA29568@fysh.org
I wrote:
>Aristotle Pagaltzis wrote:
>>But we should also figure out and supply a polyglot oneliner that says
>>"exec me under perl6 if this is a perl5",
>
>Here's a two-liner to start off with:

I figured out a one-line version, not using the delimited comment syntax:

	BEGIN { Q:exec ("perl6", $0, @ARGV) if False; die $! if False; }

The trick is that "Q:exec" for Perl 5 is a label followed by function
name, but for Perl 6 is a quote operator with an adverb.  The quote
operator uses the parens as delimiters, taking what's inside them as
string content, so that content doesn't have to make sense as Perl 6 code.

This formulation doesn't readily extend to the shell trick.  In any case,
overall I prefer the version using the delimited comment syntax.

-zefram

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