| 1 | package Treemap::Input::XML; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use XML::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | require Exporter; | |||||||||
| 10 | 1 | require Treemap::Input; | |||||||||
| 11 | |||||||||||
| 12 | 1 | our @ISA = qw( Treemap::Input Exporter ); | |||||||||
| 13 | 1 | our @EXPORT_OK = ( ); | |||||||||
| 14 | 1 | our @EXPORT = qw( ); | |||||||||
| 15 | 1 | our $VERSION = '0.01'; | |||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | # ------------------------------------------ | ||||||||||
| 19 | # Methods: | ||||||||||
| 20 | # ------------------------------------------ | ||||||||||
| 21 | |||||||||||
| 22 | sub load | ||||||||||
| 23 | 1 | ▶ | { | ||||||||
|
Subroutine
load: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 24 | 1 | my $self = shift; | |||||||||
| 25 | 1 | my( $path ) = @_; | |||||||||
| 26 | |||||||||||
| 27 | 1 | ▶ | if ( $self->{ DATA } = $self->_load( $path ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | { | ||||||||||
| 29 | 1 | return 1; | |||||||||
| 30 | } | ||||||||||
| 31 | 0 | return 0; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # ------------------------------------------ | ||||||||||
| 35 | # ------------------------------------------ | ||||||||||
| 36 | # Hey, look at that, XML loads right in as our tree map data structure. Ain't | ||||||||||
| 37 | # that handy? | ||||||||||
| 38 | # ------------------------------------------ | ||||||||||
| 39 | sub _load | ||||||||||
| 40 | 1 | ▶ | { | ||||||||
|
Subroutine
_load: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 1 | my $self = shift; | |||||||||
| 42 | 1 | my( $path ) = @_; | |||||||||
| 43 | 1 | my $tree = XMLin( $path, keyattr => {}, forcearray => [ "children" ] ); | |||||||||
| 44 | 1 | return $tree; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 1 | 1; | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||