in reply to taking file from user
-Michael#!/usr/bin/perl use strict; use warnings; print STDERR "Enter filename: "; my $fileName = <STDIN>; chomp $fileName; while (!-e $fileName) { print STDERR "\n$fileName not found.\nRe-enter filename, or +q to quit: "; $fileName = <STDIN>; chomp $fileName; exit() if $fileName eq "q"; } print STDERR "$fileName exists!\n" if -e $fileName; # <-- true if the +file exists
UPDATE: it'd probably be worth your while putting in a quit option too!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: taking file from user
by ww (Archbishop) on Jul 15, 2013 at 19:46 UTC |