my $file_from = 'test.txt'; my $file_to = 'test.gpg'; my $password = ' Blaaah'; open (my $FH, qq(| gpg --batch --passphrase-fd 0 -o "$file_to" --symmetric --cipher-algo AES256 "$file_from") ); print $FH $password; close $FH or die $!;