in reply to Print both elements in a compare

I tried this and get an uninitalized value error in the print

Are you sure the warnings comes from that line? The line you've shown produces "Use of uninitialized value in concatenation" (and not print), so maybe a different line is to blame?

Also I can recommend to use perl 5.10 or newer, it often tells you which variable was actually undefined.

That said your piece of code can produce such warnings when @array1 contains undef elements - what do you want to do in that case?

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Print both elements in a compare
by Anonymous Monk on Nov 01, 2010 at 19:05 UTC
    Unfortunately I am unable to upgrade to Perl 5.10 at the moment so need to find a solution for Perl 5.8.8
    I'm confused as to why the code produces the concatenation error as you've discovered.
    The question is how do I get it to print both sides of the mismatch and I admit I hadn't catered for undef elements. Can you advise me on how to cater for both of those issues using the code posted ?
      Can you advise me on how to cater for both of those issues using the code posted ?

      You can always use defined to check if an element is not undef, and do whatever you want with that information.

      Perl 6 - links to (nearly) everything that is Perl 6.