develooper Front page | perl.perl5.porters | Postings from December 2011

[perl #105924] require 5 << 1 vs require 5 >> 1

From:
Father Chrysostomos via RT
Date:
December 17, 2011 17:54
Subject:
[perl #105924] require 5 << 1 vs require 5 >> 1
Message ID:
rt-3.6.HEAD-14510-1324173252-1420.105924-14-0@perl.org
On Sun Dec 11 13:38:36 2011, sprout wrote:
> Sending again.... I sent this to p5p by mistake the first time.
> 
> -----
> perl5.15.5 -le' print require 5 >> $3'
> 1
> 
> $ perl5.15.5 -le' print require 5 << $3'
> Use of bare << to mean <<"" is deprecated at -e line 1.
> Can't find string terminator "" anywhere before EOF at -e line 1.
> 
> 
> Putting a number after require causes the tokenizer to expect a term
> after it.
> 
> If the token is unambiguous (>>), the parser (perly.y) has no problem
> with it.
> 
> B::Deparse with -p shows that it’s doing require((5 >> $3)).

This seems to affect barewords as well (I posted this under bug #105928,
but it actually belongs in this ticket):

$ perl5.15.5 -MO=Concise -e 'require a:: . 1'
7  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
6     <1> require sK/1 ->7
5        <2> concat[t1] sK/2 ->6
3           <$> const[PV "a::b"] s/BARE ->4
4           <$> const[IV 1] s ->5
-e syntax OK

$ perl5.15.5 -MO=Concise -we 'require a::b + 1'
Warning: Use of "require" without parentheses is ambiguous at -e line 1.
syntax error at -e line 1, near "require a::b +"
-e had compilation errors.

-- 

Father Chrysostomos




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About