|
Posted by Jim Gibson on February 5, 2008, 3:29 pm
Please log in for more thread options In article
> Hi,
>
> I am used to shell script ( bourne) and wonder how you can do the
> following in perl:
>
> (I stick to the command line input no fancy gui).
Here is one way (untested):
query:
print "Prompt [Y]: ";
my $ans = <STDIN>;
chomp($ans);
$ans = 'Y' unless $ans;
if( $ans =~ /^ty/i ) {
...
}elsif( $ans =~ /^fn/i ) {
...
}else{
print "\"$ans\" is not a valid answer\n";
goto query;
}
>
> * if user has a Y/N question and Y is default and the user only
> presses "Enter". How can I set a default answer to be used.
>
> * Also I have been wondering how I can show " dots" on the command
> line when an activity is ongoing ( to let the user know something is
> going on. Any functions that is easy to implement?
$|++;
for( $i=0; $i<30; $i++ ){
print ".";
sleep(1)
}
print "\n";
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|