Hi Jack Please refer to my program 'Simple Mail Client' under code section on www.perlmonks.org it will takes care of mail header and will allow you to work with mail body. Do let me know if it helped you ... I am working on the update. Regards Joel Jamnet Monk www.perlmonks.org At 02:30 PM 6/19/2001 -0700, Jack Lauman wrote: >Below is an example of the e-mail message I'm trying to parse, >manipulate the date, time and timzone and save it as CSV file: > > >Rates as of 2000.12.30 00:16:19 UTC (GMT). Base currency is USD. > >Currency Unit USD/Unit Units/USD >================================ =================== >=================== >USD United States Dollars 1.00000 >1.00000 >EUR Euro 0.941604 >1.06202 > >Note: >1. The line: Rates as of ..... is always at the beginning of the >message and occurs only once. > >2. All other desired lines begin with (3) capital letters. > >3. The date manipulation is done only once and is for reporting >purposes only. > >Here's the code I have so far. It correctly manipulates the date, >and all desired fields. The problem is that it parses every line >in the file, including the e-mail header and footer. > >I would appreciate any suggestions > >Thanks, > >Jack > > >#!/usr/bin/perl ># ># cur2csv.pl ># > >use strict; >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; > >use DBI; >use DBD::Pg; > >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>) { > > > # Extract date and time of Currency Rate Quotation > > ($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 date 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"); > > } > > # Extract the ISO 4217 Code for Currencies and Funds (1995) > > $cur_sym = substr($_, 0, 3); > > # Extract the Currency Description, and trim the trailing spaces > > $cur_desc = substr($_, 4, 28); > StripTSpace($cur_desc); > > # Extract US Dollars to Units rate, and trim the leading/trailing >spaces > > $usd_unit = substr($_, 35, 19); > StripLTSpace($usd_unit); > > # Extract Units to US Dollars rate, and trim the leading/trailing >spaces > > $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; -------------------------------------------------------------- QuantumLink Communications, Bombay, India