$ 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