my ($title, $artist, $mp3_file); foreach my $file (@file_names) { $mp3_file = new MP3::ID3v1Tag("$file"); $title = $mp3_file->get_title(); $artist = $mp3_file ->get_artist(); print "$title - artist\n"; } #### my ($title, $artist, $mp3_file); foreach my $file (@file_names) { print "now working with file '$file'\n"; # remove mp3_file from the my declaration outside the loop my $mp3_file = new MP3::ID3v1Tag("$file"); die "Can't create id tag : $!" unless $mp3_file; $title = $mp3_file->get_title(); $artist = $mp3_file ->get_artist(); print "$title - artist\n"; }