Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perlplexer

by sreejithcyber
on Jun 24, 2005 at 06:02 UTC ( #469611=perlquestion: print w/replies, xml ) Need Help??

sreejithcyber has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Perlplexer
by blazar (Canon) on Jun 24, 2005 at 08:05 UTC
    What is the question?

    Care to rephrase it in such a way that it does make sense? (Maybe it's just me not being a native English speaker, but I doubt that since I can make sense out of the vast majority of other posts...)

Re: Perlplexer
by holli (Abbot) on Jun 24, 2005 at 09:01 UTC
    I was really perlplexed by this one:
    print (2 + 2) * 5;
    prints "4". Huh?


    holli, /regexed monk/
      Sure it does. the parentheses around 2 + 2 make print behave as a function, so the statement parses as:

      "print the result of 2 + 2 (4) and multiply the result of print (1) times 5. That last result is discarded, because it is is void context. You can see how is is parsed:

      perl -MO=Deparse -e 'print (2 + 2) * 5' print(4) * 5; -e syntax OK

      Paul

      DB<1> print (2+2)*5; 4 DB<2> print ((2+2)*5); 20 DB<3> print 3*5; 15 DB<4> $foo=(2+2)*5; DB<5> x $foo 0 20

      Well, I guess it's some side effect to do with print.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        Shame the debugger doesn't honour -w

        P:\test>perl -wde1 perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner. Loading DB routines from perl5db.pl version 1.25 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> print (2+2)*5;; 4 DB<2> q P:\test>perl -wle"print (2+2)*5" print (...) interpreted as function at -e line 1. Useless use of multiplication (*) in void context at -e line 1. 4

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re: Perlplexer
by Tanktalus (Canon) on Jul 06, 2005 at 03:35 UTC

    Warning. Don't try it. Or at least, use a throw-away email address. Before doing this quiz, I didn't get any spam at my gmail account. Now I'm getting small amounts. Annoying.

    Bigfoot is setting up a dedicated development center in India for which they are looking for the finest Perl, Open Source programmers. The center would commence its operations in early Aug, 2005. Highlights of the opportunity with Bigfoot are: [...] A salary package that will be a trend setter in the industry.

    I'm wondering what direction this trend is being set in... (a quick check on Bigfoot's webspace shows they're a New York company ... doing development in India, and want to pay people big bucks? Something smells fishy there..)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2021-05-09 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (100 votes). Check out past polls.

    Notices?