in reply to Re: Reading Single Character Input with Term::ReadKey
in thread Reading Single Character Input with Term::ReadKey

Even clearer would be to hide that in a constant rather than having a bare magic number . . .

use constant HELP_KEY => chr( 8 ); ## Control H if( HELP_KEY() eq $key ) { ## . . . }

Alternately:

use Readonly; Readonly my $HELP_KEY => chr( 8 ); ## Control H if( $HELP_KEY eq $key ) { ## . . . }

Replies are listed 'Best First'.
Re^3: Reading Single Character Input with Term::ReadKey
by BrowserUk (Patriarch) on Apr 17, 2007 at 18:52 UTC

    I agree, but it is different advice.

    I was making suggestions on how best to define the constant. You are suggesting that he should use a symbolic constant in place of the actual constant.

    Ie. You could have made your point by suggesting

    use constant HELP_KEY => "\cH"; ## Control H

    And my point would still hold.

    As for Readonly; I "Just Say No", but that's apparently controversial :)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.