Attempt

 view release on metacpan or  search on metacpan

lib/Sub/Attempts.pm  view on Meta::CPAN

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
is inherited and not overridden) then you should use the C<method>
parameter:
 
    attempts("get_pie", tries => 3, method => 1);
 
This has the same effect as writing:
 
    sub get_pie
    {
      my $self = shift;
      $self->SUPER::get_pie(@_);
    }
 
    attempts("get_pie", tries => 3);
 
If a method is defined by a subroutine in the current package then
the C<method> parameter has no effect
 
=cut
 
sub attempts

lib/Sub/Attempts.pm  view on Meta::CPAN

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  if ($args{method})
  {
    # this eval is here as we need to switch packages to declare a
    # subroutine so SUPER works and with the current limitations of
    # perl, there's no way to do that by mucking about with
    # typeglobs.
    eval qq{package $package;
            sub $subname
            {
               my \$this = shift;
               \$this->SUPER::$subname(\@_)
            }
    };
    $old_sub = *{ $glob }{CODE};
  }
  else
  {
    croak "Can't wrap '$subname', doesn't exist in package '$package'"
  }
}



( run in 0.420 second using v1.01-cache-2.11-cpan-454fe037f31 )