#code snippet that works in another script: $cmd = "gpg --recipient $gpg_key -q --yes -e $directory/$file_name"; $rc = system($cmd); #code loop example i'm having trouble combining with #!/usr/bin/perl -w use strict; my $file = "junk"; open (FH, "< $file") or die "Can't open $file for read: $!"; my @file_name; while () { push (@file_name, $_); } close FH or die "Cannot close $file: $!"; print @file_name; # see if it worked