in reply to Extract data between certain dates using YYYYMMDDHH timestamp
Date::Manip also has nice functions for manipulating dates.
#!/usr/bin/perl use strict; use warnings; use Date::Manip; use Text::CSV_XS qw( ); my $end = UnixDate("last Friday", "%Y%m%d23"); my $start = UnixDate(DateCalc("last Friday", "- 4 days"), "%Y%m%d00"); my $csv = Text::CSV_XS->new(); while (<$fh_in>) { $csv->parse($_) or die("csv: " . $csv->error_diag() . "\n"); my ($ts) = $csv->fields(); next if $ts lt $start || $ts gt $end; print $fh_out $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extract data between certain dates using YYYYMMDDHH timestamp
by chud83 (Initiate) on Mar 22, 2009 at 22:17 UTC |