$ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8)}; my $choice = "dhcp-options(5)"; @history = (grep($_ ne $choice, @history), $choice); say "@history"' Cache::SizeAwareMemoryCache(3) BN_add_word(3) audit-packages(8) dhcp-options(5) $ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8)}; my $choice = "not-found(0)"; @history = (grep($_ ne $choice, @history), $choice); say "@history"' Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8) not-found(0) $ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8)}; my $choice = "dhcp-options(5)"; @history = (grep($_ ne $choice, @history), $choice)[0..$#history]; say "@history"' Cache::SizeAwareMemoryCache(3) BN_add_word(3) audit-packages(8) dhcp-options(5) $ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8)}; my $choice = "not-found(0)"; @history = (grep($_ ne $choice, @history), $choice)[0..$#history]; say "@history"' Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-packages(8)