Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Perl replacement for choice.com

by onelander (Sexton)
on Mar 04, 2013 at 18:19 UTC ( [id://1021689]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl replacement for choice.com
in thread Perl replacement for choice.com

I believe I know one area you were talking about but I am not certain of the second. Removing all the comments, is this what you mean?

if ( defined $default ) { my $stderr; close STDERR; open(STDERR, ">", \$stderr); my $grabkey_thread = threads->create(\&grabkey); $grabkey_thread->detach(); for ( my $i = 0; $i <= $timeout; $i++ ) { sleep 1; } my $pos = index( uc( $choices ), uc( $default ) ) + 1; print uc( $default ) . "\n"; exit $pos; } else { grabkey(); } => if ( defined $default ) { my $stderr; close STDERR; open(STDERR, ">", \$stderr); my $grabkey_thread = threads->create(\&grabkey); $grabkey_thread->detach(); for ( my $i = 0; $i <= $timeout; $i++ ) { sleep 1; } my $pos = index( uc( $choices ), uc( $default ) ) + 1; print uc( $default ) . "\n"; exit $pos; } grabkey();

Replies are listed 'Best First'.
Re^3: Perl replacement for choice.com
by Tux (Canon) on Mar 04, 2013 at 22:10 UTC

    yes, you caught both

    It is a bit of a shame you edited the original posted code, as now "new" readers will not see the changes you made based on the comments you got, and the comments now make no sense at all (for those people).

    As you learn from perlmonks, readers that stumble on this post no wdo not learn from the code changes. (FWIW By learning from changes I do not imply that all changes are always correct, but discussion about them makes you take desicions that are more thought-through.


    Enjoy, Have FUN! H.Merijn
      What is the best way to handle updates to the code? I assume leave the original code as is and then in the comments show the updates. Where is the best place to put the fully corrected version of the code?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1021689]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found