Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: wantarray alternative

by LanX (Canon)
on Jul 10, 2013 at 20:24 UTC ( #1043554=note: print w/ replies, xml ) Need Help??


in reply to Re^4: wantarray alternative
in thread wantarray alternative

before I answer this, please clarify which is the result expected for

  $name = lowercase( 'Jim',"Jeff" ) ;

???

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re^5: wantarray alternative
Download Code
Re^6: wantarray alternative
by tqisjim (Beadle) on Jul 10, 2013 at 21:04 UTC

    OK, since the day is shot anyway...

    What do experienced programmers expect? It seems like there was a lot of confusion on CB about the first or last element (both wrong).

    I expect the answer is 2, which I've confirmed by testing. But obviously, I've seen the source code.

    If I were looking at that statement without seeing the source code, I would have to test or read the source code to expect anything at all. Since the statement is called lowercase (I might've used convert_to_lowercase), one is unlikely to use this function to count the number of input arguments. So intuitively, the statement should not return 2. In summary, the point of my effort.

    The solution I'd prefer to implement would return Jim. But the most robust answer would probably be to throw an exception.

      > The solution I'd prefer to implement would return Jim.

      so first code-example in Re: wantarray alternative (Context propagation)

      > But the most robust answer would probably be to throw an exception.

      so check wantarray to do so

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2014-12-28 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls