Perl mystery

Status
Not open for further replies.

ever_thus

Baseband Member
Messages
94
I've got a script that loops through a directory using the File::Find module and has the following wanted function (where $song_ref contains the names of files pulled up using DBI::selectall_hashref):

sub wanted{
my $raw_name = $_;
$raw_name =~ s/...(.*)\.mp3/$1/;

push @{$all_files {$raw_name}}, [basename $File::Find::dir, (stat $_) [7] / 1048576] if exists $song_ref->{$raw_name};
}

Later in the script I use the following loop:

for (sort keys %all_files){
print FILE "$_\n";
printf FILE "\t%s\t%.3f\n", $_->[0], $_->[1] for @{$all_files {$_}};
print FILE "\n\n";
}

When I run this script I get the following error:

Use of uninitialized value in printf at dupes.stat.pl line 30.

Cutting up the line reveals that the value complained about is @{$all_files {$_}}. The weird part is that $_->[0] is output properly.

I'm mystified. Please enlighten me.
 
No it isn't (it wouldn't compile if it was).

P.S. The uninitialized value turns out to be $_->[1]. My mistake.
 
Status
Not open for further replies.
Back
Top Bottom