That's 'cause you have put the question inside the foreach loop:
# get all files
foreach $file (@allfiles){
$filetoopen = $path ."/" .$file;

# filter to check the type of file
print "Enter the type of extension:";
my $ext=<STDIN>;

Btw, it would be easier to just use the fileglob operator from the start (with a pattern of the form "path/*.ext"):


#! /usr/bin/perl

print "Enter a glob pattern:";
my $pattern=<STDIN>;
chomp($pattern);
my @files = glob ($pattern) ;
@files or die "serious dainbramage: $!";

foreach my $file (@files) {
print $filetoopen;
open(IN, "<$filetoopen") || die "cannot open file\n";
...

Martin


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to