CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Prompt for input in command line script

 



wjbell
stranger

Nov 14, 2001, 10:31 AM

Post #1 of 2 (469 views)
Prompt for input in command line script Can't Post

How do you prompt for input and use it in your script on the command line? I know it uses argv but I'm not exactly sure how to do it. Say I want the user to specify a directory and that input will be saved as $directory. How would I do that in perl? Also If it could have a default value if there's no input, somthing like:

Which directory are your fonts in?[/usr/share/fonts]

And if they hit enter, $directory will be /usr/share/fonts. If they enter somthing $directory will contain whatever they enter.



PerlKid
stranger

Nov 14, 2001, 12:01 PM

Post #2 of 2 (467 views)
Re: Prompt for input in command line script [In reply to] Can't Post

Each time you ask for <STDIN> Perl will pause for you to send input to the script.

ie:

Code
print qq|Where is Perl installed ?|; 
chomp (my $path = <STDIN>);


--Drew
http://www.camelsoup.com

Code
s;[\d\$&(\^)];;g+s;\.; ;g+s;(.)(..);$2$1;g+print,if$_='&61k4I.)l6il.edn7(K2e^ny$';


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives