baixiaohu has asked for the wisdom of the Perl Monks concerning the following question:
$partlist = "D:\\scripts\\partlist.txt"; #get the parts that have already been printed open(PARTS, $partlist) || die "Can't open file: $!"; @PARTS= <PARTS>; close(PARTS); #set counter $found = 0; foreach $PARTS(@PARTS) { if ($PARTS == $ordnum) { $found=1; }} if ($found eq 0){ $verifile = $outbox.$ordnum.".dat"; ##Open output file to write to open(OUTPUT_FILE, ">>$verifile")||die "Can't open file: $!"; print OUTPUT_FILE $these.$happy.$variables close OUTPUT_FILE; else { #nothing }
I know my logic is a little off, but can't seem to iron it out. Any thoughts?
update:
$partlist contains, for example, the text printfileA, I am going out to a DB getting an order number and then bringing back in with a hash... if the result of the order is printfileA.dat then it should not print since it's already been printed as indicated by $partlist. However, if my DB results show printfileA.dat and then printfileB.dat, printfileB.dat never gets created because the script stopped once it saw printfileA.dat. Sorry if I haven't been clear enough.
-Hu
Edit: g0n - code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping through a file
by almut (Canon) on Apr 15, 2008 at 20:18 UTC | |
|
Re: Looping through a file
by pc88mxer (Vicar) on Apr 15, 2008 at 20:19 UTC | |
by baixiaohu (Initiate) on Apr 15, 2008 at 20:23 UTC | |
|
Re: Looping through a file
by Erez (Priest) on Apr 15, 2008 at 20:21 UTC | |
|
Re: Looping through a file
by toolic (Bishop) on Apr 15, 2008 at 20:28 UTC | |
|
Re: Looping through a file
by apl (Monsignor) on Apr 15, 2008 at 20:23 UTC | |
by baixiaohu (Initiate) on Apr 15, 2008 at 21:01 UTC | |
by apl (Monsignor) on Apr 16, 2008 at 01:07 UTC | |
by baixiaohu (Initiate) on Apr 24, 2008 at 14:50 UTC | |
by apl (Monsignor) on Apr 24, 2008 at 14:56 UTC | |
|