in reply to Defining global variable in a subroutine

See vars. The way to make a global variable known to Perl without prefixing its full name is:

use strict; use vars qw($HELLO); $HELLO = 'Hello'; sub new_message { $HELLO = 'Nihao'; };

Replies are listed 'Best First'.
Re^2: Defining global variable in a subroutine
by ikegami (Patriarch) on Feb 22, 2012 at 16:05 UTC
    No reason not to use a lexical.
    use strict; my $HELLO = 'Hello'; sub new_message { $HELLO = 'Nihao'; }