On Jun 15, [EMAIL PROTECTED] said:
>I am trying to make subroutine which asks (via a regular expr) where some
>files are and then list them - but I would like it to jump back to the
>start of the loop if it does not find any files.
>
>The jumping part works if there are only files in the folder, as soon as
>there are files and folders it does not jump out of the loop. Can any
>body give me an idea how to break this one??
If you change the logic of your loop, you should have no problems:
sub filecheck {
my @files;
# loops until the size of @files is not zero
# (that is, loop until there's something in @files)
until (@files) {
print "Enter file glob: ";
chomp(my $file_pattern = <STDIN>);
# use grep(-e, files) to weed out false positives
# for example, glob("foo") will return "foo",
# whether or not it exists
@files = grep -e, glob $file_pattern;
}
print "Results:\n";
print " $_\n" for @files;
}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>