Subject: | use of //= in 5.10 code |
As seen on http://perladvent.pm.org/2007/19/ , syntax highlighting of
new 5.10 keywords works great, but //= tries to balance /'s oddly.
[Without the comment to balance the //'s, it emits unbalanced { error
into *.ERR file.]
I tried re-building Perl-Tidy-20071205 and running with Perl 5.10.0
after build-and-install into 5.8.8 didn't handle //=, but that did NOT
change this behavior.
Subject: | mod19.pl |
#! perl
use feature ':5.10'; # or ...
# use 5.10.0; or 5.9.5 or v5.10 or 5.010
sub hello;
while (@ARGV){
given(shift){
when("hello"){hello; }
when("hello world"){hello; }
when('Hello World'){hello; }
when(q{world}){hello; }
when(/ \b hello [-\s\W_]?+(?<Name>\w+)/ix){
hello $+{Name}; }
when(/ \A (?: false | 0{1}+ [.0]* | \s++ | ) \Z /ix){
hello 0; } # false but defined
when(/ null | undef /ix){hello undef } # undef
when(/\b hello \b/ix){hello; } #catch others
when(/(?<J>j)(?<A>a)(?<P>p)(?<H>h)/ix){
hello("$+{J}ust $+{A}nother $+{P}erl 5.10 $+{H}acker");
}
default { say "what '$_'?"; }
}
}
sub hello {
my ($msg)=@_;
state $n=0;
$msg //= 'World'; # oops
# Perl-Tidy-20071205's 5.10 compat fails on //=
say "Hello $msg",
$n++ ? " for the ${n}th time" : "";
}
Subject: | mod19.pl.html |
mod19.pl
mod19.pl
1 #! perl 2 use feature ':5.10'; # or ... 3 # use 5.10.0; or 5.9.5 or v5.10 or 5.010 4 5 sub hello; 6 while (@ARGV){ 7 given(shift){ 8 when("hello"){hello; } 9 when("hello world"){hello; } 10 when('Hello World'){hello; } 11 when(q{world}){hello; } 12 when(/ \b hello [-\s\W_]?+(?<Name>\w+)/ix){ 13 hello $+{Name}; } 14 when(/ \A (?: false | 0{1}+ [.0]* | \s++ | ) \Z /ix){ 15 hello 0; } # false but defined 16 when(/ null | undef /ix){hello undef } # undef 17 when(/\b hello \b/ix){hello; } #catch others 18 when(/(?<J>j)(?<A>a)(?<P>p)(?<H>h)/ix){ 19 hello("$+{J}ust $+{A}nother $+{P}erl 5.10 $+{H}acker"); 20 } 21 default { say "what '$_'?"; } 22 } 23 } 24 25 sub hello { 26 my ($msg)=@_; 27 state $n=0; 28 $msg //= 'World'; # oops 29 # Perl-Tidy-20071205's 5.10 compat fails on //= 30 say "Hello $msg", 31 $n++ ? " for the ${n}th time" : ""; 32 }