my $username = trim(param('username')); sub trim { my $dirty = shift; $dirty =~ s/^\s*//g; # remove leading whitespace $dirty =~ s/\s*$//g; # remove trailing whitespace return $dirty || ''; # return empty string if $dirty is undef } #### print q| Logging in ... |; #### use CGI qw(:standard); print header, start_html('Logging in ...');