while (defined($filename = $term->readline('>'))) {
Update: While you do need to check if the returned value is defined (as opposed to just false), what I suggested is not enough to fix your program. I re-read your post, and you want to read until you get a valid file name. Why then is your loop terminated when there is nothing to read? Try this:
</c>use Term::ReadLine; # Direct notation recommended over indirect notation. my $term = Term::ReadLine->new('test'); for (;;) { $filename = $term->readline('>'); die("Unable to read in filename\n") unless defined $filename; print "checking for $filename...\n"; last if -e $filename; print "File not found. Please try again\n"; } print "filename is ~~$filename~~";
In reply to Re: Term::ReadLine behaviour on a blank line
by ikegami
in thread Term::ReadLine behaviour on a blank line
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |