Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: CarTalk Puzzler

by Aristotle (Chancellor)
on Nov 18, 2005 at 13:51 UTC ( [id://509773]=note: print w/replies, xml ) Need Help??


in reply to Re: CarTalk Puzzler
in thread CarTalk Puzzler

print sqrt==int(sqrt)?1:0for 1..2e4;

:-)

You got away with it because perl is looking for an expression; when the thing it then sees starts with a digit, it can't be anything but a literal number. So the parser eats as many characters as can be part of a literal number and then stops. For some fun, insert an x right after the 0 and watch what happens; or try any number of underscores.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^3: CarTalk Puzzler
by Perl Mouse (Chaplain) on Nov 18, 2005 at 14:01 UTC
    Adding underscore doesn't add much fun. Adding an 'x' does:
    $ perl -le 'print 0for 1, 2, 3' 0 0 0 $ perl -le 'print 0_for 1, 2, 3' 0 0 0 $ perl -le 'print 0xfor 1, 2, 3' 15
    Perl --((8:>*

      True; the underscore is only interesting after trying x, and mostly for looking at the B::Deparse output.

      Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found