if ($optimize_history) { # remove duplicities from history my @history = $term->GetHistory($file); my %history = map {$_ => 1} @history; my @new_history = (); for (reverse @history) { # in reverse order if ($history{"$_"}) { # if not remembered yet unshift @new_history, $_; # remember history line delete $history{"$_"}; # and remove it } } $term->SetHistory(@new_history); # set history to new list $term->WriteHistory($file); # save history } else { # only add new line to the history file $term->WriteHistory($file); }