in reply to Uninitialized value in concatenation (.) or string?
If so, it's probably because $dir is getting set to undef, and then you are using it in string interpolation in the print statement.( $dir, $file ) = m/(.*)[\\\/](.+)/ ? ( $1, $2 ) : ( undef, $_ ); # print "$file is in the directory $dir\n"; $fileinfo[$i] = [$file, $dir];
Also, later that undef value could be causing problems in this code fragment:
The expression ${$refarray1}[1] refers to the dir component of your fileinfo structure, so if it is undef, the print statement in this fragment will also generate the same error message.$refarray1 = $fileinfo[$c]; if (${$refarray1}[0] eq $intersect) { print "File: ${$refarray1}[0] in directory ${$refarray1}[1]\n"; $matchedfiles[$i] = [${$refarray1}[0], ${$refarray1}[1]]; }
Also, don't you want to increment $i in this loop?
In general it's easier to use push: push(@matchedfiles, [ ... ]);$matchedfiles[$i++] = [${$refarray1}[0], ${$refarray1}[1]];
Update: Here are some style pointers that might make things a little cleaner.
1) Read the md5 info into a hash:
This serves two purposes: it stores the md5hash of a known bad file and it also can be used to determine if a file is a bad file by using exists:my %md5_of_known_bad; foreach $md5data (@knownbad) { ... $md5_known_bad{$filename} = $md5hash; }
if (exists $md5_of_known_bad{$filename}) { # $filename is a known bad }
2) Your intersection logic can then be simplified to:
my @uniq; @uniq = grep { exists $md5_of_known_bad{$_} } @sysfiles;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Uninitialized value in concatenation (.) or string?
by jbush82 (Novice) on May 09, 2008 at 16:29 UTC | |
by pc88mxer (Vicar) on May 09, 2008 at 16:57 UTC | |
by jbush82 (Novice) on May 09, 2008 at 17:22 UTC | |
by pc88mxer (Vicar) on May 09, 2008 at 17:54 UTC | |
by jbush82 (Novice) on May 09, 2008 at 18:36 UTC | |
|