Hi everybody, How to sort the array of two columns by the first? Would anybody enhance this code? Any sugestion? Thanks, Josimar
use File::stat; listfiles( 'C:' ); # for($i=0;$i<$count;$i++){ print "\n", $allfiles[$i][0], ' => ', $allfiles[$i][1]; } # sub listfiles{ my $folder = shift; $folder .= '\\'; opendir ( my $media, $folder ); my @files = readdir( $media ); closedir( $media ); foreach (@files){ my $sb = stat($folder . $_); ## mode 16895 or 16749 stands for subdirectory if ($sb->mode == 16895 || $sb->mode == 16749){ if ($_ ne '.' and $_ ne '..'){ listfiles( $folder . $_ ); } } else { $allfiles[$count][0] = $_; $allfiles[$count][1] = $folder; $count++; } } } ----- Original Message ----- From: "Ronen Kfir" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 19, 2003 5:08 PM Subject: RE: readir Hi, This is not I was asking for! I'll explain again: 1. Find all the places where a one specific file (with same name), is shown by read recursively all subdir of certain directory (it is a trigger file for the rest of my program). What you wrote is only the top level of the directory. 2. What I'm interested in are the paths of this file in the various directories. I need to put each of those paths as a variable. (I think in array/hash). 3. then I go to each path & from there pick up another file with same name from all different paths, then my program will go on. To make a long story short: I need the readdir switch (or anything else) for digging into subdir, & a way to put the paths I find in array/hash. Am I clear enough now? P.S. I work on Linux, Ronen Kfir System Administrator T.A.U Computing Division Tel: 972-3-6407416 Fax: 972-3-6405158 cellular: 972-55-405910 E-mail: [EMAIL PROTECTED] -----Original Message----- From: Josimar Nunes de Oliveira [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 6:21 PM To: Ronen Kfir; [EMAIL PROTECTED] Subject: Re: readir Hi, try this sample code: $dir = 'C:\\Folder\\.'; print "'\n", $dir; opendir DIR, $dir or die "Cannot open $dir: $!"; foreach (@files=readdir DIR){ print '"\n", $_; } Good luck, Josimar ----- Original Message ----- From: "Ronen Kfir" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 19, 2003 5:18 AM Subject: readir Hi, I want to use readdir to read a directory tree & find a certain file, which might be present in many subdirectories (this file will be a trigger to continue of the process). Then I want to define a few variables respectively to the number of files found in readir that will define the path of those files. Then conditioned to each path the readdir found, pick up some other file from that directory & attach it to a mail message. The part of the attachment to a mail message I have. What I miss is all the rest I have described. Thank you Ronen Kfir System Administrator T.A.U Computing Division Tel: 972-3-6407416 Fax: 972-3-6405158 cellular: 972-55-405910 E-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]