From 1f6d088c29429e7a0888d8c9d868a812d44641c6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 14 Mar 2010 11:49:36 -0400 Subject: [PATCH] Handle multiple commands typed at same second. --- merge-bash-histories.plx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/merge-bash-histories.plx b/merge-bash-histories.plx index cb32884..e6227ed 100755 --- a/merge-bash-histories.plx +++ b/merge-bash-histories.plx @@ -20,17 +20,19 @@ use strict; use warnings; my %history; +my $time; while (my $line = <>) { chomp $line; if ($line =~ /^#\s*(\d+)/) { - my $key = $1; - my $cmd; - $cmd = <>; - chomp $cmd; - $history{$key} = $cmd; + $time = $1; + } else { + $history{$time} = {} if not defined $history{$time}; + $history{$time}{$line} = 1; } } foreach my $key (sort { $a cmp $b } keys %history) { - print "#$key\n$history{$key}\n"; + foreach my $cmd (keys %{$history{$key}}) { + print "#$key\n$cmd\n"; + } }