John Kufrovich wrote:
Chas. Owens wrote:my %seen; while (<DATA>) { 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,Chas,Thanks for the help. I'm not expert but I think your code will output each line.
I'm not an expert either, but I tried Chas's code, so I know it won't. Did you try Chas's code?
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.
So, does a "temp" mean a whole line? In that case, the problem is even simpler:
my %seen; while (<DATA>) { my ($hour) = / (..)/; print unless $seen{$hour}++; }
Unfortunately, the weather logger isn't consistent enough to use read/write at the top of the hour. The minute reading will vary.
Unfortunately I don't understand what you mean by that. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/