in reply to Re^3: Treating file lines in a text file as a string
in thread Treating file lines in a text file as a string

"and and && are the same op, and or and || are the same op."
I think there is a difference (precedence) between these ops...
  • Comment on Re^4: Treating file lines in a text file as a string

Replies are listed 'Best First'.
Re^5: Treating file lines in a text file as a string
by ikegami (Patriarch) on May 22, 2008 at 17:09 UTC

    Precedence only affects parsing. The same op is used in the resulting tree for both of these operators.

    >perl -MO=Concise -e"$a and $b" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 - <1> null vK/1 ->6 4 <|> and(other->5) vK/1 ->6 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*a] s ->4 - <1> ex-rv2sv vK/1 ->- 5 <#> gvsv[*b] s ->6 -e syntax OK >perl -MO=Concise -e"$a && $b" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 - <1> null vK/1 ->6 4 <|> and(other->5) vK/1 ->6 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*a] s ->4 - <1> ex-rv2sv vK/1 ->- 5 <#> gvsv[*b] s ->6 -e syntax OK

    And check out "if":

    >perl -MO=Concise -e"if ($a) { $b }" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 3 -e:1) v ->3 - <1> null vK/1 ->6 4 <|> and(other->5) vK/1 ->6 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*a] s ->4 - <@> scope vK ->- \ The only difference - <0> ex-nextstate v ->5 / is the extra scope. - <1> ex-rv2sv vK/1 ->- 5 <#> gvsv[*b] s ->6