my $gpg_command = `gpg --trust-model always -er 12345678 my_file.txt`; print defined($gpg_command) ? $gpg_command : "Command failed\n" #### use strict; use FileHandle; my $fh = FileHandle->new('capture.out',"w"); print $fh `dir`;