> printf OUTFILE "%s\,%s\,%s\,%s\,%s\,%s\,%s\n",
> $date, $time, $tz, $cur_sym, $cur_desc, $usd_unit, $units_usd;
>
> close(INFILE);
> close(OUTFILE);
> print STDERR "\n";
>
> 1;
You seem to be misunderstanding one particular
aspect of perl. Given the following:
while (<INFILE>) {
# do something with each line encountered
# if condition, quit this while loop
}
# do something after first while loop
while (<INFILE>) {
# do something else with each line encountered
# if another condition, quit this while loop
}
# do something after second while loop
The first do something happens repeatedly until
the first condition applies or the end of INFILE
is reached, whichever comes first. In other words,
it can happen zero times, or a dozen times, or
whatever.
The 'do something after first while loop' happens once.
The second loop starts off, in terms of lines from the
INPUT file, where the first left off. Other than that, a
similar deal regarding the 'do something's applies
to this second set of perl code as it does to the first
set of perl code.
In your case, the printf is outside the loops, so it will
only happen once.
---------------------------------
Other than that, given what printed, it's clear the second
regex isn't matching at all. This isn't too surprising -- I
didn't put a lot of effort in to it, so it might just be wrong.
If it doesn't match, then the variables aren't set.
To tighten the verification a little, add:
$started or print STDERR "Didn't find a currency line";
after the second loop.
This will surely print out, which shows that the regex
didn't match. In other words:
($cur_sym, $cur_desc, $usd_unit, $units_usd) =
/^([A-Z]{3})( [A-Za-z])+\s+(\d+\.\d+)\s+(\d+\.\d+)\s*$/;
Doesn't match:
USD United States Dollars 1.00000
1.00000
I can't see why not.
One other possibility is that the second while loop
isn't even being entered; stick a print "TEST" at the
start of the second loop to verify that it is being
entered.