procmail
[Top] [All Lists]

Re: procmail/sed script for Travelocity fare updates

2001-03-05 05:20:13
On  3 Mar, Timothy Luoma wrote:
|[...]
| > The output is more sparse than yours, and reports fare difference
| > rather than old price, but otherwise has the pertinent information.
| > (It also assumes only price decreases are reported.)
| 
| It assumes incorrectly ;-)
| 
| The price watch shows increases and decreases of $25 or more (otherwise I
| would not bother to show more than the first $ amount)

Ok, allowing for price increases also (reported with or without "+"):

|perl -ne 'print(/(?:FROM|TO):\s*([^(]+)/g);\
/(\$[\d.,]+).*[^+-]([+-]?\$[\d.,]+)/ and print "$1 $2\n";'

looks like:
JACKSONVILLE, FL GLASGOW, UK $575.00 -$103.00

And if you want old price as you orginally did it, rather than price
difference:

|perl -ne 'print(/(?:FROM|TO):\s*([^(]+)/g);\
/(\$[\d.,]+).*?(\$[\d.,]+)/ and print "$1 $2\n";'

looks like:
JACKSONVILLE, FL GLASGOW, UK $575.00 $678.00

And adding From, to and was back in:
|perl -ne '/FROM:\s*([^(]+)/ and print "From: $1 " and next;\
/TO:\s*([^(]+)/ and print "to: $1  " and next;\
s/.*?(\$[\d.,]+).*?(\$[\d.,]+).*/$1 was $2/ and print;'
  
looks like:
From: JACKSONVILLE, FL  to: GLASGOW, UK   $575.00 was $678.00

Any of them will still work with multiple updates, and the same caveat
about keeping it on one-line applies. Also, they should work with commas
in the numbers too. I'm sure any of these can be done better (I tried
one regexp and gave up), but it's something to work with.

Don Hammond



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail