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?