=head2 new(foo => "bar")
-This constructs an object of the right class and returns it. Any arugments passed to the constructer will be parsed as a hash with the first argument from the pair acting as the method that should be called and the second being the argument for that method.
+This constructs an object of the right class and returns it. Any arugments passed to the constructer
+will be parsed as a hash with the first argument from the pair acting as the method that should
+be called and the second being the argument for that method.
=cut
sub new {
- my ($class, %args) = @_;
- my $self = bless {}, ref($class) || $class;
+ my ( $class, %args ) = @_;
+ my $self = bless {}, ref($class) || $class;
- for (keys %args) {
- croak "No such method '$_'" unless $self->can($_);
- $self->$_($args{$_});
- }
+ for ( keys %args ) {
+ croak "No such method '$_'" unless $self->can($_);
+ $self->$_( $args{$_} );
+ }
- return $self;
+ return $self;
}
sub trace {
- my ($self) = @_;
+ my ($self) = @_;
- my $i = 1;
+ my $i = 1;
- while (my @caller = caller $i) {
- #print join("#", map { defined $_ ? $_ : ""} @caller), "\n";
- print $caller[0], ":", $caller[2], " ", $caller[3], "\n";
- $i++;
- }
+ while ( my @caller = caller $i ) {
+
+ #print join("#", map { defined $_ ? $_ : ""} @caller), "\n";
+ print $caller[0], ":", $caller[2], " ", $caller[3], "\n";
+ $i++;
+ }
}
sub warn {
- my ($self, @message) = @_;
- print STDERR join("\n", @message), "\n";
- $self->trace;
+ my ( $self, @message ) = @_;
+ print STDERR join( "\n", @message ), "\n";
+ $self->trace;
}
1;