| 1 | package Package::New::Dump; | ||||||||||
| 2 | 2 | ▶ | use base qw{Package::New}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | our $VERSION='0.10'; | |||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Package::New::Dump - Simple base package from which to inherit | ||||||||||
| 11 | |||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||
| 13 | |||||||||||
| 14 | package My::Package; | ||||||||||
| 15 | use base qw{Package::New::Dump}; #provides new, initialize and dump | ||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | The Package::New::Dump object provides a consistent object constructor for objects. | ||||||||||
| 20 | |||||||||||
| 21 | =head1 RECOMMENDATIONS | ||||||||||
| 22 | |||||||||||
| 23 | I recommend using this package only during development and reverting back to L<Package::New> when in full production | ||||||||||
| 24 | |||||||||||
| 25 | =head1 USAGE | ||||||||||
| 26 | |||||||||||
| 27 | =head1 CONSTRUCTOR | ||||||||||
| 28 | |||||||||||
| 29 | See L<Package::New> | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | =head1 METHODS | ||||||||||
| 34 | |||||||||||
| 35 | =head2 dump | ||||||||||
| 36 | |||||||||||
| 37 | Returns the object serialized by L<Data::Dumper> | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | 5 | ▶ | sub dump { | ||||||||
|
Subroutine
dump: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 42 | 5 | my $self = shift; | |||||||||
| 43 | 5 | my $depth = shift; | |||||||||
| 44 | 5 | ▶ | $depth = 2 unless defined $depth; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 5 | local $@; | |||||||||
| 46 | 5 | ▶ | eval 'use Data::Dumper qw{}'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 47 | 5 | my $error = $@; | |||||||||
| 48 | 5 | ▶ | if ($error) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | return wantarray ? () : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | } else { | ||||||||||
| 51 | 5 | my $d = Data::Dumper->new([$self]); | |||||||||
| 52 | 5 | $d->Maxdepth($depth); | |||||||||
| 53 | 5 | return $d->Dump; | |||||||||
| 54 | } | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | =head1 AUTHOR | ||||||||||
| 58 | |||||||||||
| 59 | Michael R. Davis | ||||||||||
| 60 | |||||||||||
| 61 | =head1 COPYRIGHT | ||||||||||
| 62 | |||||||||||
| 63 | This program is free software licensed under the... | ||||||||||
| 64 | |||||||||||
| 65 | The BSD License | ||||||||||
| 66 | |||||||||||
| 67 | The full text of the license can be found in the LICENSE file included with this module. | ||||||||||
| 68 | |||||||||||
| 69 | =head1 SEE ALSO | ||||||||||
| 70 | |||||||||||
| 71 | =cut | ||||||||||
| 72 | |||||||||||
| 73 | 2 | 1; | |||||||||