for my $box (@servers) { my $ssh = Net::OpenSSH->new($box, user => $user, password => $password); if ($ssh->error) { warn "unable to connect to $box"; next; } for my $certfile (@certfiles) { my $output = $ssh->capture('openssl', 'x509', '-in', "/etc/pki/tls/$certfile", '-noout', '-subject', '-hash', '-enddate'); unless ($output =~ /notAfter=(\S+)/) { warn "expiration data not found in $box:$certfile" next; } my $notAfter = $1; ... } }