perl197 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to coble the code example below to perform work on the file name in the list. I have code that will pgp a single passed file name but I would like to loop through a file list and perform the same process against each filename in the list. How can i incorporate the $cmd component with the loop example such that each file_name in the list can be acted up on? I.e., i've tried substituting the print request with the cmd command but there's something fundamental i'm missing with this attempt
#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 (<FH>) { push (@file_name, $_); } close FH or die "Cannot close $file: $!"; print @file_name; # see if it worked
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: act on a file list
by Athanasius (Archbishop) on Jun 30, 2014 at 15:30 UTC | |
|
Re: act on a file list
by toolic (Bishop) on Jun 30, 2014 at 15:05 UTC | |
by perl197 (Novice) on Jun 30, 2014 at 20:32 UTC |