Handle multiple commands typed at same second.
This commit is contained in:
		
							parent
							
								
									1b1011d439
								
							
						
					
					
						commit
						1f6d088c29
					
				
					 1 changed files with 8 additions and 6 deletions
				
			
		|  | @ -20,17 +20,19 @@ use strict; | ||||||
| use warnings; | use warnings; | ||||||
| 
 | 
 | ||||||
| my %history; | my %history; | ||||||
|  | my $time; | ||||||
| while (my $line = <>) { | while (my $line = <>) { | ||||||
|   chomp $line; |   chomp $line; | ||||||
|   if ($line =~ /^#\s*(\d+)/) { |   if ($line =~ /^#\s*(\d+)/) { | ||||||
|     my $key = $1; |     $time = $1; | ||||||
|     my $cmd; |   } else { | ||||||
|     $cmd = <>; |     $history{$time} = {} if not defined $history{$time}; | ||||||
|     chomp $cmd; |     $history{$time}{$line} = 1; | ||||||
|     $history{$key} = $cmd; |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| foreach my $key (sort { $a cmp $b } keys %history) { | 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"; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bradley M. Kuhn
						Bradley M. Kuhn