Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PERL - pressEnter function hanging

PERL - pressEnter function hanging

PERL - pressEnter function hanging



I have a sub function called pressEnter within my perl menu script which basically means that the script will await an interaction from the user before moving on.


Unfortunately when the script goes into pressEnter it just hangs (even if you press enter!!).


Any ideas on what could be causing this?



sub checkJob



print "The current Job Status is:\n\n";

      `./scriptlist.ksh 2`;

      open OUTPUT, "./output";

      undef $/;

      $_ = <OUTPUT>;

      ($var) = m/^(INTE.*PM)$/sm;

      print "$var\n\n";

      close OUTPUT;



sub pressEnter


print "Press Return to continue\n\n";

      $dummy = <>;




I've included another sub function so you can see how it is called.

RE: PERL - pressEnter function hanging

I might suggest explicitly stating you want to read from STDIN and see if it fixes the problem:


$dummy = <STDIN>;

RE: PERL - pressEnter function hanging

thanks for the suggestion, but it still hangs. I can keep pressing enter and all it does is line feed down the terminal instead of returning to the main menu.

RE: PERL - pressEnter function hanging

I should have looked closer. It's because you're undef'ing the input record separator ($/) - normally that's set to enter, now it's undef, so hitting the enter key doesn't signify the end of a line any more.

Probably the easiest way to fix this, based on the code you posted, is something like the following:


print "The current Job Status is:\n\n";
`./scriptlist.ksh 2`;
open OUTPUT, "./output";
#undef $/;
    local $/ = undef;
    $_ = <OUTPUT>;
That way, $/ is returned to it's previous value as soon as you exit that block of code.

RE: PERL - pressEnter function hanging

Of course!! Brilliant, makes perfect sense.


RE: PERL - pressEnter function hanging


Good catch, rharsh. medal I completely missed that undef.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close