2 # The shebang is only there for mcedit syntax highlights, as I'm too lazy to
3 # change the configfile. It won't hurt performance
15 print qq{<input type=hidden name="$_" value="$hash->{$_}">}
16 unless exists $saves{$_};
23 if (defined wantarray){
36 s/\t/ /g;
39 # if ($@){ return defined wantarray ? @_ : undef }
41 return defined wantarray ? (wantarray ? @$ref : "@$ref") : undef;
44 # Browsers do s/ /+/ - I don't care about RFC's, but I do care about real-life
52 $dec =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge;
53 if (defined wantarray){
57 # return undef if $@; # ;DecodeURI("foo");
60 return defined wantarray ? (wantarray ? @r : "@r") : undef;
69 ([^;\/?:@&=\$,A-Za-z0-9\-_.!~*\'()])
71 sprintf("%%%02x", ord($1))
73 if (defined wantarray){
77 # return undef if $@; # ;EncodeURI("foo");
80 return defined wantarray ? (wantarray ? @r : "@r") : undef;
84 if ($header{'Set-Cookie'}){
85 $header{'Set-Cookie'} .= "\nSet-Cookie: $_[0]";
87 $header{'Set-Cookie'} = $_[0];
94 open (READFILE, "<$_[0]");
102 open (WRITEFILE, ">$_[0]");
104 print WRITEFILE $_[1];
111 open COUNTER, "+<$_[0]" or
112 open COUNTER, ">$_[0]" or return undef;
115 my $counter = <COUNTER>;
118 print COUNTER ++$counter;
124 # This sub assumes your string does not match /(["<>])\cC\1/
126 if (defined wantarray){
127 $ref = \(my $copy = $_[0]);
132 $$ref =~ s/"/"\cC"/g; # Single characters are easier to match :)
133 $$ref =~ s/>/>\cC>/g; # so we can just use a character class []
134 $$ref =~ s/</<\cC</g;
136 # Now this is a big, ugly regex! But hey - it works :)
137 $$ref =~ s{((\w+://|www\.|WWW\.)[a-zA-Z0-9\.\@:-]+[^\"\'>< \r\t\n]*)}{
140 s/// if (my $trailing) = /([\.,!\?\(\)\[\]]+$)/;
141 s/&(?!\x23?\w+;)/&/g;
143 my $href = ($scheme =~ /www\./i ? "http://$_" : $_);
144 qq{<a href="$href" target="_blank">$_</a>$trailing};
147 $$ref =~ s/"\cC"/"/g;
148 $$ref =~ s/>\cC>/>/g;
149 $$ref =~ s/<\cC</</g;
151 if ($@){ return defined wantarray ? @_ : undef }
152 return defined wantarray ? $$ref : undef;