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" ; }