- Removed some old commented out 2.x statements
authorplobbes <plobbes>
Wed, 30 Aug 2006 18:44:54 +0000 (18:44 +0000)
committerplobbes <plobbes>
Wed, 30 Aug 2006 18:44:54 +0000 (18:44 +0000)
- 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

index 2a9cee0..d051c74 100644 (file)
@@ -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 {