Take a look at this code I just found for the directory recursion http://www.geodata.soton.ac.uk/~hrz/personal/perl_scripts/?link=view_source. html&script=recurse.pl
For the second question, your until loop quits out as soon as the extension is correct, leaving you with no input data. Try this instead replace all of this --- print "Enter a file extension (e.g jpg): "; chomp(my $extension = <STDIN>); print "\n"; until ($extension =~ /^[A-Za-z]{3}$/) { print "Please enter a three letter extension. E.g jpg txt doc: "; chomp($extension = <STDIN>); print "\n"; } --- with this --- my $extension; do { print "Please enter a three letter extension. E.g jpg txt doc: "; chomp($extension = <STDIN>); print "\n"; } until $extension =~ /^[a-z1-9]{3}$/i; # Numbers can be in a file extension too. Make the regex case insensetive and you don't have to do A-Za-z --- HTH John -----Original Message----- From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] Sent: 04 April 2002 14:49 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: find files with .jpg extensions in directories Hi John Seems you're the only one around here. also the prev solution(RE: Opens / create file if necessary) just worked fine. Help I'm struggling to have these two pieces of codes do what I want it to do With code (1) I'm trying to recursively decends into directories to find all the files that end in .jpg. With code (2) I'm trying to read in the extentionfrom the command line. -------code(1) ----------------- #!/usr/local/bin/perl -w # first example... use strict; # declarations... my @files = `ls -F`; my @jpegs; my $extension = "jpg"; foreach ( @files ){ next if /private/i; chomp; if(/\.$extension$/){ push(@jpegs, $_); } } foreach (@jpegs) { print "$_\n"; } --------------------------------------------------------- ---------code(2) #!/usr/local/bin/perl -w # first example... use strict; # declarations... my @files = `ls -F`; my @jpegs; print "Enter a file extension (e.g jpg): "; chomp(my $extension = <STDIN>); print "\n"; until ($extension =~ /^[A-Za-z]{3}$/) { print "Please enter a three letter extension. E.g jpg txt doc: "; chomp($extension = <STDIN>); print "\n"; } print "Searching for *.$extension"; foreach ( @files ){ next if /private/i; chomp; if(/\.$extension$/){ push(@jpegs, $_); } } foreach (@jpegs) { print "$_\n"; } --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]