#!/usr/bin/perl -w use Data::Dumper qw( Dumper ); use strict; sub mycode { my $var = $_[0]; defined($var) ? print qq|mycode() called with $var\n| : print qq|mycode() called with no operands.\n|; my $foo = "blah" if $var; # does $foo become static here? print "foo is $foo\n" if $foo; $foo ||= "FOO"; } mycode("test"); # "foo is blah" mycode(); # mycode(); # "foo is FOO" mycode(); # "foo is FOO" # print Dumper(\%main::); # make sure $foo is never in symbol table #### mycode() called with test foo is blah mycode() called with no operands. mycode() called with no operands. foo is FOO mycode() called with no operands. foo is FOO #### mycode() called with test foo is blah mycode() called with no operands. mycode() called with no operands. mycode() called with no operands.