#!/usr/bin/env perl use strict; use warnings; use Time::Piece; my @dates; while () { next unless /Launching the JVM with following options/; my ($date, $line) = split /::/,$_,2; $date = Time::Piece->strptime($date, "----- %a %b %d %T %Y"); push @dates, [ $date, $line ]; } for (@dates) { print $_->[0]->strftime("%Y-%m-%d %T") . " $_->[1]"; } __DATA__ ----- Sun Mar 8 10:51:20 2015::4426::Launching the JVM with following options. # 2015-03-08 10:51:20 4426::Launching the JVM with following options.