[ale] awk question
James Baldwin
jbaldwin at antinode.net
Tue Apr 5 10:55:17 EDT 2005
On 5 Apr 2005, at 01:47, Christopher Bergeron wrote:
> Guys - I have another seemingly trivial question that I can't seem to
> figure out. Does anyone have a one-liner that can convert a line
> like this:
>
> 'ab_ba_ab_ba','mfljwis at yahoo.com','12/15/2001'
>
> into a line like this:
>
> 'ab_ba_ab_ba','mfljwis at yahoo.com','1008392400'
I couldn't come up with a oneliner since I've never figured out how to
properly escape complex perl scripts using -e.
Direct from the perl cookbook:
#!/usr/bin/perl -w
use Time::Local;
use strict;
while(<STDIN>) {
my($data, $email, $date) = split(',', $_);
$date =~ s/'//g;
my($month, $day, $year) = split('/', $date);
my $time = timelocal(0, 0, 0, $day, $month - 1, $year - 1900);
print("$data,$email,\'$time\'\n");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
More information about the Ale
mailing list