|Welcome to the Monastery|
Re: Use of shift in Ternary Operatorby hipowls (Curate)
|on Mar 22, 2008 at 23:00 UTC||Need Help??|
The problem is that ? is ambiguous, is it part of a ternery operator or the start of a ?? match? From Perl Regular Expressions Reference
?pattern? is like m/pattern/ but matches only once. No alternate delimiters can be used. Must be reset with reset().puting () after shift resolves the ambiguity.
Update:To explain further, shift expects a single argument which is an expression that evaluates to an array. If no argument is provided it defaults to @_. When perl sees shift ? it doesn't know if you mean
or something like
the parentheses forces the first interpretation and shift defaults to using @_.