You could do this:

$started=0;
while(<file>)
{
        $started = 0 if($_ =~ "<PRE>" && $started);
        $started = 1 if($_ =~ "<PRE>" && !$started);
        print $_ if($started);   ## Will print in between the <PRE>'s

}


Ryan


On Mon, 18 Jun 2001, Jack Lauman wrote:

> I wrote the following to read a daily email that is is sent in ASCII
> and contains currency exchange rates.
>
> I want to search the file and look for <PRE> and process all of the
> lines that follow it until it encounters a second <PRE>.
>
> The code as it stands works, put it also processes all the garbage
> above and below the actual working area of the file.
>
> I would appreciate any help in resolving this issue as well as any
> comments on better coding practices.
>
> Regards,
>
> Jack
>
>
> #!/usr/bin/perl
> #
> # cur2sql.pl
> #
>
> use strict;
> use vars qw($proc_begin $proc_end);
> use vars qw($quote_date $cur_sym $cur_desc $usd_unit $units_usd);
> use vars qw($year $month $mday $hour $minute $second $timezone);
> use vars qw($conv_date $date $time $tz);
>
> use Date::Manip;
> use String::Strip;
>
>
> open (OUTFILE, ">", "currency.csv") || die "Can not open currency.csv
> for writing";
>
> printf STDERR "Reading currency file";
> open (INFILE, "curtest") || die "Can not open /var/spool/mail/currency
> for reading";
>
> while (<INFILE>) {
>
>           $quote_date = substr($_,0,79);
>           ($year, $month, $mday, $hour, $minute, $second, $timezone) =
>           $quote_date = /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+)
> (\w+) (.*)$/;
>           $year     = $1;
>           $month    = $2;
>           $mday     = $3;
>           $hour     = $4;
>           $minute   = $5;
>           $second   = $6;
>           $timezone = $7;
>
>           # Convert date from UTC (GMT) to PST and adjust adte and time
> accordingly.
>
>           $tz = &Date_TimeZone;
>           $conv_date = "$year-$month-$mday $hour:$minute:$second";
>           $conv_date = &ParseDate($conv_date);
>           $conv_date = &Date_ConvTZ($conv_date, $timezone, $tz);
>           $date = &UnixDate($conv_date,"%Y-%m-%d");
>           $time = &UnixDate($conv_date,"%H:%M:%S");
>           $tz = &UnixDate($conv_date,"%Z");
>
>           $cur_sym  = substr($_, 0, 3);
>           $cur_desc = substr($_, 4, 28);
>           StripTSpace($cur_desc);
>
>           $usd_unit = substr($_, 35, 19);
>           StripLTSpace($usd_unit);
>
>           $units_usd = substr($_, 57, 19);
>           StripLTSpace($units_usd);
>
>       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;
>




Reply via email to