There are several defined ways of differentiating scripts as a whole. A minimal approach allows for a bare literal in void context at the beginning:
5; print "I'm Perl 5 code\n";
6; say "I'm Perl 6 code";
Or if you want to make sure strictness is on, you use
Those are okay for the script as a whole, but I hate to think about what happens when people start cutting and pasting snippets. Certainly Perl 6 could disallow snippets
starting with "5;
", but Perl 5 would currently
accept a "6;
" unless you had warnings turned on. One could go with "5:
" and "6:
" instead, but that's a syntax error in Perl 5 currently.
Of course, there's always the tried and true:
print "I'm Perl 5 code\n"; # Perl 5
say "I'm Perl 6 code"; # Perl 6
But that doesn't help much with cut-and-paste errors...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||