Created
February 24, 2012 07:50
-
-
Save sortega/1898835 to your computer and use it in GitHub Desktop.
Annotate text input to expand epoch timestamps to normal time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
sub tag { | |
my $epoch = shift; | |
return "$epoch=<".(scalar (localtime $epoch)).">"; | |
} | |
sub tag_line { | |
my $line = shift; | |
$line =~ /^(.*?)(\d{9,})(.*)$/; | |
my $tagged = $1; | |
$tagged .= tag($2) if $2; | |
$tagged .= tag_line($3) if $3; | |
return $tagged; | |
} | |
while (my $line = <>) { | |
print tag_line($line); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment