For my own sake, and others I hope, why do you have to do ~~ rx:perl5/([XO])\1\1/ instead of just plain old =~ /([XO])\1\1/?
The old pattern-match-binding operator =~ has been usurped by the smart match operator ~~, and "regular expressions" have been reworked in Perl6 to "rules". The old regular expression engine will still be there, but you have to use the vaguely ugly rx:perl5// syntax, or rx:P5// will work too (I think). The reason he used a P5 regex in the code is because Pugs doesn't have Perl6 rules support yet.
| [reply] [d/l] [select] |
Yes, as of 6.2.1, P5 works, as do Perl5 and perl5.
| [reply] |
~~ is called the "smart match operator" and supersedes the binding operator, =~. It allows you to use it on anything and it'll do the right thing, ie:
$i = 1; if ( $i ~~ 1 ) { # $i == 1
$i = 'foo'; if ( $i ~~ 'foo' ) { # $i eq 'foo'
$i = 'foo'; if ( $i ~~ m/fo(.)/ ) { # $1 contains 'o'
Read the "Smart Matching" section of Synopsis 4 for details.
rx is a replacement for qr. rx:perl5 means use perl5-compatible regular expressions. More details about rx in Synopsis 5.
| [reply] [d/l] [select] |
Thanks for the links. Are we sure this new language is perl? I mean it looks like perl, but it sure aint the same thing. Anyone else completly terrified by the need to learn a new language? I know it is not a need, and it does look quite cool, but I just feel like i'm getting the hang of 5.8. ;)
| [reply] |
Are we sure this new language is perl? I mean it looks like perl, but it sure aint the same thing.
It's certainly not the same, but to me it still feels like Perl. A lot has changed, but the spirit seems very much intact.
Anyone else completly terrified by the need to learn a new language? I know it is not a need, and it does look quite cool, but I just feel like i'm getting the hang of 5.8.
Well, as you said, it's not something you're going to need to do right away. Perl 5 is not going away any time soon, so your skills will be useful for a long time to come.
Even if Perl 5 was taken away from us the moment Perl 6 was released, much of the language is only changed in a superficial sense. In general, the old ways will still be there for the taking, they'll just be sometimes clunky and obtuse compared to the shiny new ways of solving the same problems.
PS: if anyone wonders why I've posted so much in this thread, it's because I'm excited about Perl6, and welcome any discussion about it. Hopefully that doesn't come across as obsessed and attention crazed, but sometimes you take that risk. :-)
| [reply] |