Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Perl oddities

by Mugatu (Monk)
on Mar 01, 2005 at 17:04 UTC ( #435527=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl oddities
in thread Perl oddities

But it doesn't have a (native) switch.

No fair, picking on explicit design decisions. :-)

Warn (wrongly) for one particular function

What's wrong about the warning? It's there to prevent the common pitfall of expecting things like this to work right:

print (stat)[9];

And seems like a perfectly reasonable warning. Many other warnings are special-cased and very specific, so I don't know why you chose this one.

Update: I didn't realize the warning would trigger with one and only one space. That does seem kind of peculiar. But if that was the crux of what the OP was talking about, it wasn't exactly clear.


Comment on Re^2: Perl oddities
Download Code
Re^3: Perl oddities
by QM (Vicar) on Mar 01, 2005 at 23:55 UTC
    What's wrong about the warning? It's there to prevent the common pitfall of expecting things like this to work right:
    print (stat)[9];
    His point was the warning cares about exactly one space. Why it shouldn't it give the same warning for these also?
    print(stat)[9] print (stat)[9]
    is obtuse. I'm sure there are a hundred root nodes on this site alone about abuse of white space, so I'll defer to them.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Re^3: Perl oddities
by Anonymous Monk on Mar 02, 2005 at 13:09 UTC
    As noted, I find the oddity in that it warns about exactly one space - althought it doesn't do that always:
    perl -wle 'print ("foo")' # Warning perl -wle 'print ("foo");' # No warning perl -wle 'print (")");' # Warning perl -wle 'print ("\x29");' # No warning
    Now, I know why it's happening (I've studied the source), and I also know what the intent is, but that's beside the point. brian asked about oddities, and I do find this an oddity.

    But the single space is not the only thing that I find an oddity. I also find it odd (as in, irregular, different that you would expect based on how similar constructs are handled - you know, what brian was asking for - so spare me the explainations on why it is this way - I know already) that is only has these warnings for print and I think one other function. For other functions, it doesn't warn.

    $ perl -wle 'print ("foo") . "bar"' print (...) interpreted as function at -e line 1. Useless use of concatenation (.) or string in void context at -e line +1. foo $ perl -wle 'my $s = length ("foo") . "bar"'
    Why warn only with print and a single space, but not with length or other functions? Or other amounts of whitespace? That I find an oddity.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://435527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-11-29 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (204 votes), past polls