Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Perl bug ?

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

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

the first call of ok():
the first argument is $errors && ($errors->[0] =~ /.../i) which results in $errors being passed as the first argument. before it is passed, array element 0 gets autovivivied though by usage in the second argument.

the second call:
$errors is now true, so the matching is executed and its result would the empty string ("false"). but since the matching is executed in list context, the result is an empty list, so what you wrote as a second argument becomes now the first argument.

Replies are listed 'Best First'.
Re^4: Perl bug ?
by vsespb (Chaplain) on Feb 06, 2013 at 12:36 UTC
    Why I have
    [[[ARRAY(0x137cd48)]]] [[[some text 1 ]]]
    then ? First argument should be true only if $errors->[0] contains string /Journal file not found/ no ?
      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)
        what gets really passed is $errors
        Why? I would expect the result of the && operation to be passed.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017405]
[Corion]: marto: Redoing something on new infrastructure sounds fun. At least you can reuse your previous experience :)
[marto]: I'm looking forwads to it. The video sources are dying, and they don't have the hardware to play them back (old tape formats, not just VHS + Laserdisc etc)
[marto]: I'll be interested to see what difference in terms of file size/quality the new codecs make. I enjoy working on things like this, so that's a bonus
[Corion]: Ah, cool! So it's not an inhouse youtube but for a wider consumption
[marto]: last time it was IE6 clients, now they're on 11, so more scope there also, in terms of UI and playback
[marto]: in house as in Company network, not internet connected (power stations and the corporate HQs)
[Discipulus]: new Monsignor party! free beverages and pizza for all you monks! and a big thanks for the patience you deserved me during these years
[marto]: congrats Discipulus
[Discipulus]: only 4k points to sundial's level ..;=)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-07-28 09:19 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (425 votes). Check out past polls.