Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-03-2006, 09:40 PM   #1 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 94

ever_thus

Default Perl mystery

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.
ever_thus is offline  
Old 04-09-2006, 11:08 PM   #2 (permalink)
 
Master Techie

Join Date: Apr 2004

Posts: 2,534

horndude is on a distinguished road

Default

missing a "{"
horndude is offline  
Old 04-15-2006, 06:04 PM   #3 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 94

ever_thus

Default

No it isn't (it wouldn't compile if it was).

P.S. The uninitialized value turns out to be $_->[1]. My mistake.
ever_thus is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On