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 , -SandhyaIn reply to system commands aren't working as a loop. by smanicka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |