$ perl -E 'my @x = qw{A B C D}; @x = grep $_ ne "B", @x; say "@x"' A C D #### $ perl -E 'my @x = qw{A B C D}; my $y = "B"; @x = (grep($_ ne $y, @x), $y); say "@x"' A C D B #### $ perl -E 'my @x = qw{A B C D}; my $y = "Z"; @x = (grep($_ ne $y, @x), $y); say "@x"' A B C D Z #### $ perl -E 'my @x = qw{A B C D}; my $y = "Z"; @x = (grep($_ ne $y, @x), $y)[0..$#x]; say "@x"' A B C D #### $ perl -E 'my @x = qw{A B C D}; my $y = "B"; @x = (grep($_ ne $y, @x), $y)[0..$#x]; say "@x"' A C D B #### $ 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)