in reply to print_notice or print $notice or print notice?

Or this:
use constant NOTICE => 'please be sure that XXX is installed first'; # many lines later print NOTICE;
And, if ever internationalisation becomes an issue, you can change the text to suit:
if ($language eq 'perlmonks_terse') { use constant NOTICE => 'do perlfaq XXX, use strict; and use CGI;'; } elsif ($language eq 'aussie') [ use constant NOTICE => 'install the bloody XXX first, you dopey dr +ongo'; } else { use constant NOTICE => 'please be sure that XXX is installed first +'; }

Replies are listed 'Best First'.
Re: Re: print_notice or print $notice or print notice?
by wog (Curate) on Oct 14, 2001 at 22:24 UTC
    Unfortunatly, that method for changing the text for internationalization won't work. use constant is evaluated at compile-time, thus if code is compiled, a use constant in it will take effect, to illustrate this:

    #!/usr/bin/perl -w use strict; use constant TEST => 'outside'; if (0) { use constant TEST => 'if(0)'; } print TEST, "\n"; __END__ outputs: Constant subroutine TEST redefined at ... if(0)
Re: Re: print_notice or print $notice or print notice?
by tstock (Curate) on Oct 14, 2001 at 23:53 UTC
    use constant NOTICE => { aussie => 'install bloody ...', perlmonks => 'perldoc XXX...', portuguese => 'que ?' }; print NOTICE->{$language};
Re: Re: print_notice or print $notice or print notice?
by Anonymous Monk on Oct 14, 2001 at 22:34 UTC

    The use statements are compile time so trying to define constants based on runtime data as in your example is not going to work as you might expect. You'd want to wrap up any code to determine the $notice in a BEGIN block and follow it up with a use constant NOTICE => $notice;