LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-06-2009, 05:33 PM   #1
nobody123
LQ Newbie
 
Registered: Feb 2009
Location: Toronto, ON
Distribution: Fedora 10
Posts: 16

Rep: Reputation: 0
Perl - Press Any Key To Continue


Hi all,
I was hoping to find a solution on the forums regarding this topic but the closest result that I got was in BASH programming. I just need to know if there is a way to "press any key to continue" in PERL. Any help is appreciated. If anyone needs more information, just let me know
 
Old 04-06-2009, 05:43 PM   #2
sjmarshy
LQ Newbie
 
Registered: Mar 2009
Location: United Kingdom
Distribution: Fedora 10
Posts: 17

Rep: Reputation: 0
you could just do

print "any key to continue:";
<>;
 
Old 04-06-2009, 05:58 PM   #3
nobody123
LQ Newbie
 
Registered: Feb 2009
Location: Toronto, ON
Distribution: Fedora 10
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sjmarshy View Post
you could just do

print "any key to continue:";
<>;
Well, that's sorta right. What exactly I am aiming for is when the user presses the key, the program exits. No pressing a key and pressing enter. Just one key, then exit. Thanks for the reply, though.
 
Old 04-06-2009, 07:10 PM   #4
sjmarshy
LQ Newbie
 
Registered: Mar 2009
Location: United Kingdom
Distribution: Fedora 10
Posts: 17

Rep: Reputation: 0
well just make it a bit more complex

while ($flag) {

#whatever code you want here

$input = <>;
if ($input =~ /\S\s/) {
$flag = 0;
}
}

i think that's all characters...

to be honest, I don't think that there's a command to do what you want, you'd have to work around it as far as I'm aware. I'm only a perl novice myself
 
Old 04-06-2009, 07:52 PM   #5
nobody123
LQ Newbie
 
Registered: Feb 2009
Location: Toronto, ON
Distribution: Fedora 10
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sjmarshy View Post
well just make it a bit more complex

while ($flag) {

#whatever code you want here

$input = <>;
if ($input =~ /\S\s/) {
$flag = 0;
}
}

i think that's all characters...

to be honest, I don't think that there's a command to do what you want, you'd have to work around it as far as I'm aware. I'm only a perl novice myself
Hi again! Solved the problem (finally found documentation from goggle). I'll just post the code used here for anyone that is interested:

Code:
use Term::ReadKey;
ReadMode('cbreak');
$key = ReadKey(0);
ReadMode('normal');
And here's how I implemented it with my code (as an example of course):
Code:
if (%addresses == null)   #checking if array has nothing in it
{
print "\n"; print "Nothing stored in records...\n"; print "\nPress any key to continue..."; use Term::ReadKey; ReadMode('cbreak'); $key = ReadKey(0); ReadMode('normal');
} else {
print "\n"; print %addresses; print "\nPress any key to continue..."; use Term::ReadKey; ReadMode('cbreak'); $key = ReadKey(0); ReadMode('normal');
}
Thank's again for your help.

Last edited by nobody123; 04-07-2009 at 12:11 AM. Reason: Epic Gramical Mistake
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scripting question press any key to continue Mr.McCormick Programming 3 02-04-2005 04:47 AM
boot failed: please change disks and press a key to continue bonovox86uk Red Hat 2 12-08-2004 05:16 PM
HEELLLP! Boot failed: please change disks and press any key to continue GeekFreak Red Hat 8 09-01-2004 04:51 AM
Boot failed: please change disk and press a key to continue zeewin Linux - Software 4 01-05-2004 11:39 PM
Boot failed: please change disks and press a key to continue. ChriSchmi Linux - Software 9 03-13-2002 02:34 PM


All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration