in reply to Re^3: Uninitialized value in concatenation (.) or string?
in thread Uninitialized value in concatenation (.) or string?

I'm confused as to why $dir is undefined. The line:

print "$file is in the directory $dir\n";

Produces the output that I'm looking for, the file and the directory it is in:
Ascent.jpg is in the directory C:\WINDOWS\Web\Wallpaper Autumn.jpg is in the directory C:\WINDOWS\Web\Wallpaper Azul.jpg is in the directory C:\WINDOWS\Web\Wallpaper Bliss.bmp is in the directory C:\WINDOWS\Web\Wallpaper Crystal.jpg is in the directory C:\WINDOWS\Web\Wallpaper Follow.jpg is in the directory C:\WINDOWS\Web\Wallpaper Friend.jpg is in the directory C:\WINDOWS\Web\Wallpaper Home.jpg is in the directory C:\WINDOWS\Web\Wallpaper Moon flower.jpg is in the directory C:\WINDOWS\Web\Wallpaper Peace.jpg is in the directory C:\WINDOWS\Web\Wallpaper Power.jpg is in the directory C:\WINDOWS\Web\Wallpaper Purple flower.jpg is in the directory C:\WINDOWS\Web\Wallpaper Radiance.jpg is in the directory C:\WINDOWS\Web\Wallpaper Red moon desert.jpg is in the directory C:\WINDOWS\Web\Wallpaper Ripple.jpg is in the directory C:\WINDOWS\Web\Wallpaper Stonehenge.jpg is in the directory C:\WINDOWS\Web\Wallpaper Tulips.jpg is in the directory C:\WINDOWS\Web\Wallpaper Vortec space.jpg is in the directory C:\WINDOWS\Web\Wallpaper
Which is just the listing of the files and what directory they are in. If it is successfully printing output, would that not indicate that it is defined?

Replies are listed 'Best First'.
Re^5: Uninitialized value in concatenation (.) or string?
by pc88mxer (Vicar) on May 09, 2008 at 17:54 UTC
    The print statement will still work - an undef value will print as the empty string.

    Sorry, I mistook line 71 for a similar looking line (the one in the foreach $intersect (@uniq) loop.)

    If this is where you problem is:

    my $refarray3 = $matchedfiles[5]; print "File: ${$refarray3}[0] in directory ${$refarray3}[1]\n";
    then maybe $refarray3 is undef. How many elements are there in the @matchedfiles array?
      I'm trying to pass two elements per row. The filename and the MD5 value.

      print "\n\n"; my $refarray3 = $matchedfiles[5]; print "it's not defined!\n" unless defined(${$refarray3}[0]); print "it's not defined!\n" unless defined(${$refarray3}[1]); print "File: ${$refarray3}[0] in directory ${$refarray3}[1]\n";
      Both of the elemnts in the 5th row of the matchedfiles array show the output of not being defined. It seems as if nothing is being passed to the array, when back on line 63 I have the following:

      push(@{$matchedfiles[$c]}, [${$refarray1}[0], ${$refarray1}[1]]); I've updated the main post with the latest code.
        Maybe that statement is never getting executed when $c is 5 - it's in an if statement after all. What's so special about 5?

        You should just dump the entire @matchedfiles array to see what you have:

        use Data::Dumper; print Dumper(\@matchedfiles);