use Net::OpenSSH; my $ssh = Net::OpenSSH->new('us@pp'); my @out = $ssh->capture('grep', '-i', '-e', '^AAA=', '-e', '^XXXXX AAA=', "$dir/$file");