Perl: the Markov chain saw | |
PerlMonks |
Re^3: Why should any one use/learn Perl 6?by liz (Monsignor) |
on Jun 14, 2018 at 08:20 UTC ( [id://1216615]=note: print w/replies, xml ) | Need Help?? |
I've done some reading but not that Perl 5 code can be dropped into Perl 6. Indeed, you can not. But like the Queen's English vs American English, they look very much alike. With subtle differences. -> became ., . became ~, sigils don't vary, and you must put a comma after the block in a map. But by and large, you can write Perl 5-style in Perl 6, just as you can write C-style in Perl 5. Even moreso if you use P5built-ins, which exports a growing number of functions (currently at 100 or so) that exist in Perl 5, with the same semantics as in Perl 5. Think about things like tie, opendir, pack/unpack, but also things that exist in Perl 6 but have magic attached (such as shift shifting from @_ or @ARGV by default). I thought barewords were bad practice. Indeed they are, they don't exist in Perl 6. A sigilless variable needs to be defined: it usually indicates an alias. E.g. in a for loop:
Or as a direct alias to a value in a hash:
So, no, those are not barewords like Perl 5 has them. Perl 5 will happily accept say BAR as valid syntax, Perl 6 does not (unless you have defined BAR in that scope).
And yes, all of Perl 5 CPAN is available at your fingertips if you have Inline::Perl5 installed. The only thing you need to do, is to add :from<Perl5> to your use statement, so e.g.
It really can't get much simpler than that, I would say, thanks to all the hard work of Stefan Seifert
In Section
Seekers of Perl Wisdom
|
|