For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > capture a carriage return from <STDIN>









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author capture a carriage return from <STDIN>
D. J. Birkett

2005-04-20, 3:56 pm

I have a script that pauses while the reader reads the intro text, and
askes them to press return to continue. At the moment I capture the
input from STDIN into a variable called $waste, do nothing with it, and
continue anyway. The script complains when it runs...

Name "main::waste" used only once: possible typo at ./addUsers line 66.

Is there a better way of doing this?
John Moon

2005-04-20, 3:56 pm

Subject: capture a carriage return from <STDIN>

I have a script that pauses while the reader reads the intro text, and
askes them to press return to continue. At the moment I capture the
input from STDIN into a variable called $waste, do nothing with it, and
continue anyway. The script complains when it runs...

Name "main::waste" used only once: possible typo at ./addUsers line 66.

Is there a better way of doing this?


I don't know if it's "better" but you may wish to consider:

....
print q{To continue, please press "Enter":};
<>;
....
John W. Krahn

2005-04-20, 3:56 pm

D. J. Birkett wrote:
> I have a script that pauses while the reader reads the intro text, and
> askes them to press return to continue. At the moment I capture the
> input from STDIN into a variable called $waste, do nothing with it, and
> continue anyway. The script complains when it runs...
>
> Name "main::waste" used only once: possible typo at ./addUsers line 66.
>
> Is there a better way of doing this?


Yes, don't capture the input.

print 'Press return to continue.';
<STDIN>;
# continue running the program


John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com