Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: A Perl aptitude test

by silent11 (Vicar)
on May 02, 2003 at 17:50 UTC ( #255103=note: print w/replies, xml ) Need Help??


in reply to Re: A Perl aptitude test
in thread A Perl aptitude test

I get 64. Why?

-silent11

Replies are listed 'Best First'.
Re: A Perl aptitude test
by ferrency (Deacon) on May 02, 2003 at 17:59 UTC
    You actually get a "6" followed by a "4".

    print (print (2 * 3) + 3);
    The inner print(2 * 3) is evaluated first: it prints 6, and returns the value "1" because the print succeeded. 1 + 3 is 4, so the outer print prints 4. There were no delimiters between the two digits, so they look like one number instead of two sequential digits.

    This brings up the original trick question quite nicely: the parentheses on print (2 * 3) + 3 make print() look like a function call, they aren't simply an arithmetic grouping operator in this case.

    Alan

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255103]
help
Chatterbox?
[muthusathish]: i dont have source code too
[muthusathish]: it is used in VB 6 appln, while debugging is getting error
[hippo]: Somebody has. Ask the author.
[Eily]: muthusathish ok, the fact that you can't tell what perl has to do with it proves it: this is not perl

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2018-02-23 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (301 votes). Check out past polls.

    Notices?