foreach (@pairs) {
s/\s*(.*?)\s*/$1/;
.
.
.
}
####
push @strings, 'nospace';
push @strings, 'trailingspace ';
push @strings, ' leadingspace';
push @strings, 'internal space';
push @strings, ' surroundedbyspace ';
push @strings, ' spaces every where ';
for my $wtf (@strings)
{
print "Before: '$wtf'\n";
$wtf =~ s/\s*(.*?)\s*/$1/;
print "After: '$wtf'\n\n";
}
####
Before: 'nospace'
After: 'nospace'
Before: 'trailingspace '
After: 'trailingspace '
Before: ' leadingspace'
After: 'leadingspace'
Before: 'internal space'
After: 'internal space'
Before: ' surroundedbyspace '
After: 'surroundedbyspace '
Before: ' spaces every where '
After: 'spaces every where '
####
# Fetch a list of cookies from the environment or the incoming headers and
# return as a hash. The cookie values are not unescaped or altered in any way.
sub raw_fetch {
my $class = shift;
my $raw_cookie = get_raw_cookie(@_) or return;
my %results;
my($key,$value);
my(@pairs) = split("; ?",$raw_cookie);
foreach (@pairs) {
s/\s*(.*?)\s*/$1/;
if (/^([^=]+)=(.*)/) {
$key = $1;
$value = $2;
}
else {
$key = $_;
$value = '';
}
$results{$key} = $value;
}
return \%results unless wantarray;
return %results;
}