lib.pl ------------- package lib; use vars '%common'; %common = ( 'username' => " " ); sub untaint_username { my $tainted = shift; # patern match letters and numbers for 1-16 characters (inclusive) $tainted =~ s/\W//g; # remove all non word characters if ($tainted =~ /\A([a-zA-Z0-9]{1-16})\z/i) { return $1; } # behold a username else {print "failure\n";} } 1; #### ----------------- prog.pl ----------------- #!/usr/bin/perl -wT use strict; require './lib.pl'; $lib::common{username}="unixhelp"; $lib::common{username}=lib::untaint_username($lib::common{username});