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 10:14
Subject:
Re: 5.24.0 + cpan
Message ID:
20160517101431.GL3613@fysh.org
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.)

-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