LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 04: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, 04: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, 04: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, 06: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, 06: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-06-2009 at 11:11 PM. Reason: Epic Gramical Mistake
 
  


Reply



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 03:47 AM
boot failed: please change disks and press a key to continue bonovox86uk Red Hat 2 12-08-2004 04:16 PM
HEELLLP! Boot failed: please change disks and press any key to continue GeekFreak Red Hat 8 09-01-2004 03:51 AM
Boot failed: please change disk and press a key to continue zeewin Linux - Software 4 01-05-2004 10:39 PM
Boot failed: please change disks and press a key to continue. ChriSchmi Linux - Software 9 03-13-2002 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:52 PM.

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
Open Source Consulting | Domain Registration