Subject: | undefined user_agent cause warning message |
Normally I expect that the user_agent is always set, but last weeks I
often see warnings about an undefined value in pattern match with
user_agent. So I changed the small function to ensure user_agent is set.
Cheers
Heiko
Subject: | user_agent_patch.txt |
*** /usr/local/lib/perl5/site_perl/5.8.8/CGI.pm.orig Thu Aug 30 15:37:38 2007
--- /usr/local/lib/perl5/site_perl/5.8.8/CGI.pm Thu Aug 30 15:46:59 2007
***************
*** 2970,2977 ****
'user_agent' => <<'END_OF_FUNC',
sub user_agent {
my($self,$match)=self_or_CGI(@_);
! return $self->http('user_agent') unless $match;
! return $self->http('user_agent') =~ /$match/i;
}
END_OF_FUNC
--- 2970,2978 ----
'user_agent' => <<'END_OF_FUNC',
sub user_agent {
my($self,$match)=self_or_CGI(@_);
! my $user_agent = $self->http('user_agent');
! return $user_agent unless $match && $user_agent;
! return $user_agent =~ /$match/i;
}
END_OF_FUNC