use warnings; use strict; use IPC::Run3::Shell [ aws => {fail_on_stderr=>1}, "/path/to/aws" ]; use Cpanel::JSON::XS qw/decode_json/; use Data::Dumper; my $PROFILE = 'MyProfile'; # aws configure --profile=MyProfile my $buckets = decode_json( aws(qw/ s3api --output json --profile /, $PROFILE, 'list-buckets') ); print Dumper($buckets);