[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
> 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
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00009" href="msg00009.html">[ale] Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> mdhirsch at gmail.com (Michael Hirsch)</li></ul></li>
<li><strong><a name="00011" href="msg00011.html">[ale] Re: Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> mdhirsch at gmail.com (Michael Hirsch)</li></ul></li>
<li><strong><a name="00019" href="msg00019.html">[ale] Re: Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> mdhirsch at gmail.com (Michael Hirsch)</li></ul></li>
<li><strong><a name="00033" href="msg00033.html">[ale] Re: Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> rramsdell at adelphia.net (Randy Ramsdell)</li></ul></li>
<li><strong><a name="00035" href="msg00035.html">[ale] Re: Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> adrin at bellsouth.net (H. A. Story)</li></ul></li>
<li><strong><a name="00097" href="msg00097.html">[ale] Re: Anyone having problems with comcast now?</a></strong>
<ul><li><em>From:</em> mdhirsch at gmail.com (Michael Hirsch)</li></ul></li>
<li><strong><a name="00115" href="msg00115.html">[ale] awk question</a></strong>
<ul><li><em>From:</em> christopher at bergeron.com (Christopher Bergeron)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00116.html">[ale] running Konqueror as non-root + lan:/ ioslave + "illegal" port assignment for NFS</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00118.html">[ale] awk question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00115.html">[ale] awk question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00118.html">[ale] awk question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00117"><strong>Date</strong></a></li>
<li><a href="threads.html#00117"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>