Me wrote:
>
> Analysis of the code you attached.
>
> $quote_date = substr($_,0,79);
>
> The above line is pointless.
>
---> Agreed.
> The next couple lines are great:
>
> ($year, $month, $mday, $hour, $minute, $second, $timezone) =
> $quote_date = /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+)
> (\w+) (.*)$/;
>
> Although as I indicated, you could omit $quote_date and just do:
>
> ($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.
>
> Everything that follows is working on the last line
> from the file. That makes no sense.
>
> -------------------
>
> Ignoring that, you code makes no sense anyway.
>
> Your code has statements like this:
>
> /^[A-Z]{3} /;
>
> These do absolutely nothing.
>
---> Agreed.
> -------------------
>
> 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.
> # 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. Looses the date values.
> # if we've matched a currency line, note that we've started:
> $cur_sym and $started++;
>
> # if we have not matched a currency line, and we've started,
> # well, then we've ended, and if we haven't started, we need
> # to move on to the next line:
> not $cur_sym and ($started and last) or next;
>
> # Now we have a matching line. Process variables as required.
>
> # One variable has one bit of space we don't want:
> substr($cur_desc, 0, 1) = ''; # get rid of leading space.
> }