I have a Perl script that should work on both Perl 5 and Perl 6. If I use Perl6, I need to use “perl6 :: Form”, and on Perl5 I need to use “Format”.
This code works on both versions or perl without errors:
BEGIN { if( $] ge 6){ require Perl6::Form; Perl6::Form::->import(); } }
But I do not know how to "separate" the Perl6 code when working on Perl5.
if( $] ge 6){ # Perl6 print form ... ... } else { # perl5 format STDOUT = ... ... }
This does not work cleanly since I get errors in Perl5:
Unquoted string "form" may clash with future reserved word at /usr/bin/script.pl line 628. Name "main::form" used only once: possible typo at /usr/bin/script.pl line 641.
I looked briefly at Text::CPP , but I do not want to have a dependency on the installed compiler. We appreciate any suggestions.
source share