> > ($year, $month, $mday, $hour, $minute, $second, $timezone) =
> > /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/;
> >
> > The following code is pointless:
> >
> > $year = $1;
> > $month = $2;
> > $mday = $3;
> > $hour = $4;
> > $minute = $5;
> > $second = $6;
> > $timezone = $7;
> >
> > -------------------
> >
> > Then you end the while loop!
>
> ---> Disagree, The code is very relavent and allows the manipulation
of
> the date, time and timezone using Date::Manip before it is written to
> the file.
Well, the $year = $1 etc are definitely pointless.
The statement immediately prior has just set
the variables, so the $year = $1 simply overwrites
their values with exactly the same values as were
just assigned. Try:
($year, $month, $mday, $hour, $minute, $second, $timezone) =
/^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/;
print $year;
$year = $1;
print $year;
and you will see that $year doesn't change in
between prints.
The ending of the loop is ok, but it means you'v
ended the loop. So the subsequent lines aren't
in a loop, so they all work on whatever happened
to be the last line in the input. Which is not what
you want. As I said:
> > Everything that follows is working on the last line
> > from the file. That makes no sense.
> > Try the following and see if it works. Post to the list if there are
any
> > problems with it.
> >
> > while (<INFILE>) {
> >
> > ($year, $month, $mday, $hour, $minute, $second, $timezone) =
> > /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+)
(.*)$/;
> >
> > $year and last; # if we've matched the date line, then bail
out.
> >
> > eof and print STDERR "Didn't find date line";
> > }
> >
> > print OUTFILE "$month/$year...";
> >
>
> ---> Returns empty strings.
I've taken another look, and I would expect it to either
print the error or print the match.
change the final print line to something like:
print OUTFILE "TEST: $month/$year...";
and see if the 'TEST' appears.
If it does, well, it's as if the <INFILE> loop isn't happening.
> > # Now have date info and we're part way through file
> >
> > while (<INFILE>) {
> >
> > ($cur_sym, $cur_desc, $usd_unit, $units_usd) =
> > /^([A-Z]{3})( [A-Za-z]+)+\s+(\d+\.\d+)\s+(\d+\.\d+)\s*$/;
> >
>
> --> Truncates $cur_desc after first word.
I've reflected briefly, and I've no idea on that.
I can't see how it's possible.
> Looses the date values.
Eh? What's this part got to do with the date values?
How can setting these variables have anything to do
with the other variables? I suspect I don't understand
your terminology here.