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
shift(@_) ? 1: 2;
or something like
shift ?pattern? ? @a: @b;
the parentheses forces the first interpretation and shift defaults to using @_.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|