Created
August 27, 2010 22:01
-
-
Save sirhc/554278 to your computer and use it in GitHub Desktop.
Simple example of overriding a method in CGI.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyCGI; | |
use base 'CGI'; | |
use strict; | |
our $ShowAll = 0; # set via $MyCGI::ShowAll | |
sub a { | |
my ( $self, @param ) = @_; | |
my $a = $self->SUPER::a(@param); | |
my ( $href ) = $a =~ m{href="([^"]*)"}; | |
$href .= $href =~ /[?]/ | |
? "&a=$ShowAll" | |
: "?a=$ShowAll"; | |
$a =~ s{href="[^"]*"}{href="$href"}; | |
return $a; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment