Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: Perl bug ?

by tinita (Parson)
on Feb 06, 2013 at 12:48 UTC ( #1017413=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Perl bug ?
in thread Perl bug ?

like I said. the first argument passed to ok() is $errors && ($errors->[0] =~ /.../i). what gets really passed is $errors. it's like saying: my @foo = $errors && ($errors->[0] =~ /.../i)
the pattern match isn't executed at all at the first time. but after processing the first argument, you use $errors->[0] in your second argument. now $errors is autovivified to an array ref before ok() is actyally executed. since $errors is passed as the first argument as an alias, it prints ARRAY(0x137cd48)


Comment on Re^5: Perl bug ?
Select or Download Code
Re^6: Perl bug ?
by choroba (Abbot) on Feb 06, 2013 at 12:55 UTC
    what gets really passed is $errors
    Why? I would expect the result of the && operation to be passed.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      I would expect the result of the && operation to be passed.
      yes, and the result of something_false && something is something_false. the second part is never processed.
        Oh, I see! Thanks for enlightening me.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Now I get it, thanks. Agree. That's probably most amazing way to shut yourself 3 times in one line of Perl.

Log In?
Username:
Password:

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

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

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





    Results (163 votes), past polls