If the "query" parameter is the last one, that regex will fail...eg....
search.cgi?this=that&query=hello
...because there's no trailing "&".
I may be wrong but I think on some occasions the HTTP_REFERER variable will be undefined and so trying to perform a regex on it will trigger a warning.
Code:
sub {
require Links; import Links qw/$IN/; # I'm guessing on the package name as I don't use Links SQL.
my $referer = defined $ENV{HTTP_REFERER} ? $IN->unescape($ENV{HTTP_REFERER}) : '';
my $query = '';
if ($referer =~ m/query=([^&;]+)/) {
$query = $1;
}
return $query;
}