Grokbase
x

Re: 5.8.0, possible parsing bug?

View PostFlat  Thread  Threaded | < Prev
Fergal Daly Re: 5.8.0, possible parsing bug?
paperclip | +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Wednesday 12 March 2003 01:12, Joshua Hoblitt wrote:
> BUT...
>
> perl -ew '1?:1'
>
> No error???
>
> -J

The problem is that perl -ew is not the same as perl -we. When it's after the
-e, the w is taken as a piece of perl code eg try

perl -edie

or

perl -e'some fabby one-liner'

so

perl -ew '1?:1'

is actually the same as

perl -e 'w' '1?:1'

So your script is just the bareword w which is treated as a string when not in
strict mode. Try perl -w -ew to see a warning about it.

2 reasons for not requiring a space between -e and the perlcode you want to
execute are: it let's you knock off 1 character in a game of Perl golf and
that's the way it's always been so changing it could break existing
one-liners.

Would a warning be appropriate? The patch attached adds Perl warn

No space between -e and script body

when it occurrs, although the Perl golfers are definitely not going to like
that so I doubt this patch is going in,

F

--
Do you need someone with lots of Unix sysadmin and/or lots of OO software
development experience? Go on, giz a job.
My CV - http://www.fergaldaly.com/cv.html

Attachment: espace.diff

Thread : 5.8.0, possible parsing bug?
1)
Joshua Hoblitt This seems to only pop up when doing a one liner. Is this a bug in the parser or a feature? I...
2)
Kay Roepke Feature. Definitely. :-) I don't. You can always write "( )" instead. perl -ew '1?:1' is *not* the...
3)
Joshua Hoblitt My bad. That still doesn't explain......
4)
Fergal Daly 1?:1 is incorrect Perl. perl -e '1?:1' will also give a syntax error. The problem was previously...
5)
Joshua Hoblitt That is a very good answer to my question. So now on to question #2: Why isn't '1?:1' valid Perl?...
6)
Kay Roepke The ?: operator is ternary, i.e. requires three arguments. The first, in front of the '?' is the...
7)
Fergal Daly isn't '1?:1' valid Perl? Explicitly saying undef or 0 or whatever is not that much work and doesn't...
8)
Joshua Hoblitt Ok, lets drop this off list after this post. undef and a null list are not equivalent. What I'm...
9)
Ronald J Kimball If you want to return an empty list, then specify an empty list: Your example *is* a syntax error;...
10)
Fergal Daly think a null list should be the default value returned if nothing is defined. As more often then...
11)
Rafael Garcia-Suarez Use another parser generator than yacc ?
12)
Aaron Sherman Woohoo! Now you're talking. I'll whip out the Parse::RecDescent manpage and have you a Perl grammar...
13)
Rafael Garcia-Suarez It's fine for perl to rely on bison extensions, perl sources are distributed with an...
14)
Fergal Daly the big Oops didn't mean to post that to the list, not for fear of offending but for fear of anyone...
15)
Enache Adrian if if .. else line-numbers problem isn't the parser's fault anyway. Perl will print the correct...
16)
Fergal Daly The problem is that perl -ew is not the same as perl -we. When it's after the -e, the w is taken as...
paperclip
spacer
View PostFlat  Thread  Threaded | < Prev