http://qs321.pair.com?node_id=11108595

flieckster has asked for the wisdom of the Perl Monks concerning the following question:

Hello, i'm trying to remove the suffix from a list of filenames. what is the best way to apply the basename module to a list of files.?
#!/usr/bin/env perl use Net::FTP; use File::Copy; use Mail::Sender; use Net::SMTP; my $TIFFfolder = "/Volumes/photorepos/Partners/LTBrands/post/DONE_PSDs +/"; chdir( $TIFFfolder ) or warn "Cant chdir to $TIFFfolder $!"; my(@TIFFfolder_list) = glob "*.psd"; print "$date $time Removing any Thumbs.db files from $TIFFfolder\n"; if ( -e "Thumbs.db") { unlink ("Thumbs.db") or warn "thumbs.db is being a pain in the ass: $! +\n"; } my $TIFFapproval = @TIFFfolder_list; foreach $file (@TIFFfolder_list){ my $file = basename (@TIFFfolder_list, ".psd"); print "$file\n"; } $mail->send(-to=>"$to", -from=>"$from", -subject=>"$subject", -body=>" +$file", -contenttype=>"text/html"); $mail->bye;
when i run this the print function will print the same filename for as many times as there are files it globbed, and doesn't make it into my email. LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT