Chas, Thanks for the help. I'm not expert but I think your code will output each line. The output I'm trying to achieve. --Output--. h:m:s 2007-01-23 00:01:00,43.3,34.9,30.14,North,359,7,8,72,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 01:11:00,42.9,34.8,30.13,North,1,5,6,73,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 02:14:00,43.2,34.1,30.10,North,0,16,16,70,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 03:04:00,43.2,34.1,30.11,North,0,7,12,70,0.00,,,0.00,Wunderground v.1.13, It should cover up to 23 hrs but get the first reading for that hour. It will read the file and parse the first temp of each hour. Unfortunately, the weather logger isn't consistent enough to use read/write at the top of the hour. The minute reading will vary. jk jk
"Chas. Owens" <[EMAIL PROTECTED]> wrote: On Jan 26, 2008 9:38 AM, John Kufrovich wrote: > Time,TemperatureF,DewpointF,PressureIn,WindDirection > 2007-01-23 00:01:00,43.3,34.9,30.14,North,359,7,8,72,0.00,,,0.00,Wunderground > v.1.13, snip > What I am trying to accomplish is pull the first temp for each hour. I have > tried various combinations of regex and none seem to correctly on hr:min:sec. snip Out of "2007-01-23 01:11:00,42.9," you want 01 and 42.9. The first thing to notice is that the first time a space shows up in the data is right before what we want. This is wonderful. It will act as our first anchor point. We then need to capture the next two characters (the hour) then anything up to (and including) the next match a comma, and finally capture anything up to the next comma. So, now we need to translate that into a regex. our anchor point: / / capture two characters: /(..)/ match anything up to (and including) the next comma: /.*?,/ capture anything up to (but not including) the next comma /(.*?),/ Put it all together and you get: / (..).*?,(.*?),/. You also mentioned that you only want the first temp for each hour. Whenever you hear the words unique, first, or last, your brain should scream "hash!": #! /usr/bin/perl use strict; use warnings; my %seen; while () { my ($hour, $temp) = / (..).*?,(.*?),/; print "temp was $temp at $hour\n" unless $seen{$hour}++; } __DATA__ 2007-01-23 00:01:00,43.3,34.9,30.14,North,359,7,8,72,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 00:06:00,43.2,34.8,30.14,North,354,11,11,72,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 00:12:00,43.2,34.8,30.14,North,1,6,9,72,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 01:11:00,42.9,34.8,30.13,North,1,5,6,73,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 01:17:00,42.9,34.8,30.12,NNW,346,3,7,73,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 01:23:00,43.1,35.0,30.12,North,359,5,11,73,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 02:14:00,43.2,34.1,30.10,North,0,16,16,70,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 02:19:00,43.2,34.1,30.09,North,0,6,13,70,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 02:24:00,43.2,33.7,30.09,North,349,8,14,69,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 03:04:00,43.2,34.1,30.11,North,0,7,12,70,0.00,,,0.00,Wunderground v.1.13, 2007-01-23 03:09:00,43.2,34.1,30.11,North,0,10,17,70,0.00,,,0.00,Wunderground v.1.13, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/