use strict; use XML::Rules; use Text::CSV_XS; use FileHandle; my $csv = Text::CSV_XS->new({eol => "\n"}); my $parser = XML::Rules->new( rules => [ _default => 'content', HOUR_DATA => sub { $csv->print( $_[4]->{parameters}, [ map {$_[1]->{$_}} qw( LOCATION_NAME EFFECTIVE_DATE HOUR CLC DPT HUM DBT WDR WSP HIX WCH ) ]); return; } ] ); open my $FH, '>&STDOUT'; print $FH "# relation, date, time, CloudCoverPct, DewPointF, Humidity, TempF, WindDirection, WindMPH, HeatIndexF, WindChillF\n"; $parser->parse( \*DATA, $FH); __DATA__ KCNU 20 73 82 84 79 79 210 17 08/20/2007 14:00 08/20/2007 09:45:00 KCOU 100 71 87 79 75 75 190 13 08/20/2007 14:00 08/20/2007 09:45:00