[ { "wan" : 0, "lan" : 0, "name" : "HTTP", "wan1" : 0, "lan1" : 0 } ] #### use stricts; use warning; use json; # function : sub get_stats { my ($self,$option) = @_; my $cmd = 'cmd'; #command goes here $self->execute($cmd); #$self->output() contains the json output. my $decoded = decode_json($self->output() ); my @out = @{ $decoded->{$self->output()} }; foreach my $line ($self->output( ) ); print $line -> {$option} . "\n" ; } #### $self->{'stats_obj'} = Statistics->new( ip => "ip addr"); my $result = $self->{'stats_obj'}->get_stats('wan'); INFO('Status of the task is :' . $result );