Skip to content

Instantly share code, notes, and snippets.

@sirhc
Created August 27, 2010 22:01
Show Gist options
  • Save sirhc/554278 to your computer and use it in GitHub Desktop.
Save sirhc/554278 to your computer and use it in GitHub Desktop.
Simple example of overriding a method in CGI.pm
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