in reply to Re^2: Why should any one use/learn Perl 6?
in thread Why should any one use/learn Perl 6?

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:

for @foo -> \element { say element }

Or as a direct alias to a value in a hash:

my %hash; my \foo = %hash<FOO>; dd %h; # Hash %h = {} foo = 42; dd %h; # Hash %h = {:FOO(42)}

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).

$ perl6 -e 'say BAR' ===SORRY!=== Error while compiling -e Undeclared name: BAR used at line 1

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.

use DBI:from<Perl5>; use DBD::mysql:from<Perl5>; my $dbh = DBI.connect(...); # call DBI->connect(...) under the hood

It really can't get much simpler than that, I would say, thanks to all the hard work of Stefan Seifert