CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl Tk script is listing all directory files instead of just the ones I need

 



sunblaster
Novice

Nov 4, 2011, 5:58 PM

Post #1 of 1 (233 views)
Perl Tk script is listing all directory files instead of just the ones I need Can't Post

I have a script that makes several copies of a single file then prints the file names of the copies to a TK txt box, But it prints the entire directory files in the txt box while giving me the "Unable to list files" error.
All the copied files have a(x) in the files name, so I am using

Code
if $list =~ /\(/

in the function just to get those filenames.


Code
sub makeCopies{ 
while ($count < 5){
chdir getcwd;
print "$fn\n";
open (FN, $fn) or warn "Unable to open file:$!";
copy($fn,"($count)$fn") or warn "Unable to copy:$!";
$count++;
}
opendir(DD, $dd) or warn "Unable to open directory";
while ($list = readdir(DD)) {
#print "$list\n";
$txt -> insert('end',"$list\n") if $list =~ /\(/ or warn "Unable to list files:$!";
}
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives