If you want a more object oriented approach you can modify App::Config like this
#!/usr/bin/perl
#
#
use strict;
use warnings;
package AppConfig;
use 5.014;
use strict;
use warnings;
use autodie;
use Carp;
use Exporter qw(import);
# Module specific imports
use XML::Twig;
our $VERSION = 1.00;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(getAppConfig);
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK, );
sub new {
my $class = shift;
my $self = {};
my %passed_params = @_;
croak "Please provide filename\n" unless (defined $passed_params{f
+ilename});
$self->{filename}= $passed_params{filename};
bless( $self, $class );
return $self;
}
sub getAppConfig {
my ($self) = @_;
my ( %config, $twig, $root );
$twig = XML::Twig->new();
$twig->parsefile->( $self->{filename} );
$root = $twig->root;
$config{'ppSK'} =
$root->first_child('pp')->first_child('ppSK')->text;
return \%config;
}
# End.....
1;
And use the module like this
#!/usr/bin/perl
use 5.014;
use strict;
use warnings;
use autodie;
use AppConfig qw(:all);
use Data::Dumper;
my $app_config = AppConfig->new('filename' => '/home/john/tmp/config.x
+ml');
my %config=getAPPConfig();