What modification do I need so the menu (and script) stays alive until
5 is entered?
Running this script from the command line.
GAry
---------Code------------
#!/usr/local/bin/perl
while ($choice != 5) {
print <<MENU;
Command Menu
1. Current date
2. Users currently logged in
3. Working directory
4. Contents of working directory
5. Quit
Enter a choice:
MENU
chomp($choice=<>);
if ($choice == 1) {exec 'date';}
if ($choice == 2) {exec 'who';}
if ($choice == 3) {exec 'pwd';}
if ($choice == 4) {exec 'ls';}
}
exit;
Sent via Deja.com http://www.deja.com/
Before you buy.
From the first 5 lines of 'perldoc -f exec':
exec LIST
exec PROGRAM LIST
The `exec' function executes a system command and
never returns-- use `system' instead of `exec' if
you want it to return.
--
John J. Trammell
johntr...@yahoo.com
> How do you make a system call without the Perl program terminating
> after the call?
Hey look another self-answering question for the collection!
By "make a system call" he actually means "run an external program".
What I can't understand how anyone could say "make a system call" when
they mean "run an external program" and yet still ask this question.
Gary, if you haven't figured it out yet then here's a fishing lesson.
Look at your code. Figure out from context what function is being
used to call the external programs. Read the manual entry for that
function (at least as far as the second sentence).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
Thanks
In article <8t4a60$8ob$1...@nnrp1.deja.com>,
gary....@usafa.af.mil wrote:
> (See code below)
> How do you make a system call without the Perl program terminating
> after the call? Below is a simple menu, if you select one menu item
> and the system call gets executed, the Perl script terminates
> (gracefully).
>
> What modification do I need so the menu (and script) stays alive until
> 5 is entered?
>
> Running this script from the command line.
>
> GAry
>
> ---------Code------------
>
> #!/usr/local/bin/perl
>
> while ($choice != 5) {
>
> print <<MENU;
> Command Menu
> 1. Current date
> 2. Users currently logged in
> 3. Working directory
> 4. Contents of working directory
> 5. Quit
> Enter a choice:
> MENU
>
> chomp($choice=<>);
> if ($choice == 1) {exec 'date';}
> if ($choice == 2) {exec 'who';}
> I just love all the extra commentary (by some users) one gets when
> posting a question for help in discussion groups!
Wierd that, you post question to a _discussion_ group as an
alternative to spending 5 minuites reading the manual and you get all
this totally undeserved sarcastic commentry! I guess that all us
regulars here need the learn that the purpose of a language discussion
group is to replace manuals for newbies.
Get real! This is a discussion group not a helpdesk. You post
something we discuss it's implications. If the discussion happens to
answer a question you've asked that's incidental. If you post a
question that implies that you've got a problem finding answers to
trivial questions in the manual then it is perfectly reasonable for us
to discuss how to do that.
> "Maybe some day I'll get REAL smart, too!"
Or at least learn some basic netiquette - like how to qoute the
message you are responding to.