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

Re: 5.24.0 + cpan

Thread Previous | Thread Next
May 17, 2016 10:14
Re: 5.24.0 + cpan
Message ID:
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:

	BEGIN { exec "perl6", $0, @ARGV; die $!; } )

(Delimited comment syntax hides the whole BEGIN block from Perl 6, whereas
Perl 5 will execute it.)  This can also be combined with the shell hack:

	eval 'exec perl6 "$0" ${1+"$@"}';
	BEGIN { exec "perl6", $0, @ARGV; die $!; } )

(Shell executes the eval statement straight away; Perl 5 compiles it to
an eval op, but the BEGIN means it never gets round to executing it.)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About