{ #anonymous block to establish a limited lexical scope no strict 'refs'; # yes yes its evil, but i have no choice for my $sub (qw(foo bar baz)) { *$sub =sub { #insert a new subroutine into the appropriate glob using symrefs # ... }; } # All done with our symrefs now, normality has returned. } #### use strict; use warnings; #Now all I have to worry about is bad logic, not silly mistakes. my %things; # hey its lexically scoped, nobody is going to step on this by accident. $things{wonderful}="A good Thing to behold"; my @var=(qw(wonder ful)); # more lexicals... my $join_var=join("",@var); my $perlmonks = $things{$join_var} || die "Sorry, unknown thing '$join_var'" #In this sample $perlmonks is equal to #"A good Thing to Behold"; #### print "We know about the following things ".join(" ",keys %things)."\n"; print "Which have the following values ".join(" ",values %things)."\n"; #### # warning warning warning # this code is dangerous and stupid # DO NOT USE IT OR COPY IT OR ASSUME IT IS USEFUL # IT IS PURELY AN EXAMPLE OF WHAT NOT TO DO $wonderful="Wasn't that wonderful!"; $wondercmd="ls"; $var=$ARGV[0]; $$var=$ARGV[1]; print `$wondercmd`,"\n",$wonderful; #### do_not_do_this.pl wondercmd 'rm -rf /'