Skip to content

Instantly share code, notes, and snippets.

@sortega
Created February 24, 2012 07:50
Show Gist options
  • Save sortega/1898835 to your computer and use it in GitHub Desktop.
Save sortega/1898835 to your computer and use it in GitHub Desktop.
Annotate text input to expand epoch timestamps to normal time.
#!/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