smanicka has asked for the wisdom of the Perl Monks concerning the following question:
Yesterday, I was so glad to get the first part of a script up and running with your help, that i just left home without testing to see if the program would work if made into a loop.
This now works fine.But if i put it into a loop,to do the same action with all the files in a directory, the script exits saying it cannot open $file for reading.Any idea why this is happening? I must have made some stupid mistake that eludes me.Could anyone help?#!usr/bin/perl -w use strict; my @cmd=qw(lpr -S SYSTEMX -P QGPL/SPYVIEW -o l C:\\ABCDEFGH.txt); system(@cmd)==0 or die "cannot do this";
#!usr/bin/perl -w use strict; my @files=<c:\\ascii\\*>; foreach my $file(@files){ my @cmd=qw(lpr -S SYSTEMX -P QGPL/SPYVIEW -o l $file); system(@cmd)==0 or die "cannot do this"; }
Is there a problem with the system command that it won't run in a loop or is there anything else I have made a mistake with?
Thanks , -Sandhya
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: system commands aren't working as a loop.
by ikegami (Patriarch) on Feb 12, 2009 at 17:20 UTC | |
|
Re: system commands aren't working as a loop.
by Corion (Patriarch) on Feb 12, 2009 at 17:18 UTC | |
|
Re: system commands aren't working as a loop.
by mr_mischief (Monsignor) on Feb 12, 2009 at 17:30 UTC | |
by smanicka (Scribe) on Feb 12, 2009 at 17:40 UTC | |
|
Re: system commands aren't working as a loop.
by smanicka (Scribe) on Feb 12, 2009 at 17:27 UTC | |
by ikegami (Patriarch) on Feb 12, 2009 at 17:31 UTC |