in reply to Argument "" Isn't numeric in numeric eq (==)

The following code returns the same results as yours, but no warnings. In my eyes, it is even more readable.
my ($success, $fail) = (0, 0); for my $i (0 .. @f / 2) { if (($f[1 + $i * 2] || 0) == 1) { $success = 1 if ($f[$i * 2 + 2] || 0) == 1; $fail = 1 if ($f[$i * 2 + 2] || 0) == 2; } }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Argument "" Isn't numeric in numeric eq (==)
by karlgoethebier (Abbot) on Feb 09, 2014 at 16:14 UTC

    This looks really cool. But how did you manage it before?

    Imho it looks like CSV and the OP needs to do something like my @f = split ',', $data;.

    This yields:

    $VAR1 = [ '1', '1' ];

    And after casting it:

    $VAR1 = [ 1, 1 ];

    What do i miss (or perhaps yet another mental block)?

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      I do not understand the question. I just populated the @f array as in the OP. I just used
      while (<DATA>) { my @f = (undef, split /,/);

      as the @f in the OP is not zero based, but one based. There is no need to cast between strings and numbers in Perl.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        "There is no need to cast..."

        Yes s(h)ure. I was a bit confused about this Isn't numeric in numeric eq (==). Sorry, i couldn't explain it better :-(

        Best regards, Karl

        «The Crux of the Biscuit is the Apostrophe»