X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FCGI%2FEx.pm;h=b18f5ee204ac76a90a441fddb6e0de043379363a;hb=6ab8b2e8e8388d1a238148a1ee58e124855f3768;hp=4b3b8a86493fe87c89cf68e00e2d51ddfbeccae6;hpb=b6e904ff7b346908d0662aae9a9c5f7d976dd85e;p=chaz%2Fp5-CGI-Ex diff --git a/lib/CGI/Ex.pm b/lib/CGI/Ex.pm index 4b3b8a8..b18f5ee 100644 --- a/lib/CGI/Ex.pm +++ b/lib/CGI/Ex.pm @@ -7,7 +7,7 @@ CGI::Ex - CGI utility suite - makes powerful application writing fun and easy =cut ###----------------------------------------------------------------### -# Copyright 2007 - Paul Seamons # +# Copyright 2003-2012 - Paul Seamons # # Distributed under the Perl Artistic License without warranty # ###----------------------------------------------------------------### @@ -24,7 +24,7 @@ use vars qw($VERSION use base qw(Exporter); BEGIN { - $VERSION = '2.17'; + $VERSION = '2.37'; $PREFERRED_CGI_MODULE ||= 'CGI'; @EXPORT = (); @EXPORT_OK = qw(get_form @@ -163,7 +163,7 @@ sub make_form { my $val = $form->{$key}; $key =~ s/([^\w.\-\ ])/sprintf('%%%02X', ord $1)/eg; $key =~ y/ /+/; - foreach (ref($val) ? @$val : $val) { + foreach (ref($val) eq 'ARRAY' ? @$val : $val) { my $_val = $_; # make a copy $_val =~ s/([^\w.\-\ ])/sprintf('%%%02X', ord $1)/eg; $_val =~ y/ /+/; @@ -195,7 +195,7 @@ sub get_cookies { my %hash = (); foreach my $key ($obj->cookie) { my @val = $obj->cookie($key); - $hash{$key} = ($#val == -1) ? next : ($#val == 0) ? $val[0] : \@val; + $hash{$key} = ($#val == -1) ? "" : ($#val == 0) ? $val[0] : \@val; } return $self->{'cookies'} = \%hash; } @@ -417,7 +417,7 @@ sub time_calc { return time + ($m->{lc($3)} || 1) * "$1$2"; } else { my @stat = stat $time; - die "Could not find file \"$time\" for time_calc" if $#stat == -1; + die "Could not find file \"$time\" for time_calc. You should pass one of \"now\", time(), \"[+-] \\d+ [smhdwMy]\" or a filename." if $#stat == -1; return $stat[9]; } } @@ -486,7 +486,7 @@ sub print_js { ### get file info my $stat; - if ($js_file && $js_file =~ m|^(\w+(?:/+\w+)*\.js)$|i) { + if ($js_file && $js_file =~ m|^/*(\w+(?:/+\w+)*\.js)$|i) { foreach my $path (@INC) { my $_file = "$path/$1"; next if ! -f $_file; @@ -979,6 +979,10 @@ that the javascript will cache. Takes either a full filename, or a shortened name which will be looked for in @INC. (ie /full/path/to/my.js or CGI/Ex/validate.js or CGI::Ex::validate) + #!/usr/bin/perl + use CGI::Ex; + CGI::Ex->print_js($ENV{'PATH_INFO'}); + =item C<-Eswap_template> This is intended as a simple yet strong subroutine to swap