From 2627584a8ec11ec8b680bafc314ffa1c1721a491 Mon Sep 17 00:00:00 2001 From: plobbes Date: Wed, 30 Aug 2006 18:44:54 +0000 Subject: [PATCH] - Removed some old commented out 2.x statements - set $VERSION using eval per modperlstyle - new() now will strip off multiple leading dashes before calling build_subs NOTE: we should probably have it remove any \W to make perl happy - required_fields() now croaks with a list of missing fields --- OnlinePayment.pm | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/OnlinePayment.pm b/OnlinePayment.pm index 2a9cee0..d051c74 100644 --- a/OnlinePayment.pm +++ b/OnlinePayment.pm @@ -1,24 +1,14 @@ package Business::OnlinePayment; use strict; -use vars qw($VERSION); # @ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use vars qw($VERSION); use Carp; use Symbol; require 5.005; -#use Data::Dumper; - -#require Exporter; - -#@ISA = (); #qw(Exporter AutoLoader); -#@EXPORT = qw(); -#@EXPORT_OK = qw(); $VERSION = '3.00_04'; -sub VERSION { #Argument "3.00_01" isn't numeric in subroutine entry - local($^W)=0; - UNIVERSAL::VERSION(@_); -} +$VERSION = eval $VERSION; # modperlstyle: convert the string into a number my %fields = ( is_success => undef, @@ -59,7 +49,7 @@ sub new { foreach(keys %data) { my $key = lc($_); my $value = $data{$_}; - $key =~ s/^\-//; + $key =~ s/^\-+//; $self->build_subs($key); $self->$key($value); } @@ -148,10 +138,14 @@ sub content { sub required_fields { my($self,@fields) = @_; + my @missing; my %content = $self->content(); foreach(@fields) { - Carp::croak("missing required field $_") unless exists $content{$_}; + push(@missing, $_) unless exists $content{$_}; } + + Carp::croak("missing required field(s): " . join(", ", @missing) . "\n") + if(@missing); } sub get_fields { -- 2.11.0