Skip to content

Instantly share code, notes, and snippets.

@0xAF
Created May 30, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xAF/3d82ab50515c4a1c6762a1ea9bac3846 to your computer and use it in GitHub Desktop.
Save 0xAF/3d82ab50515c4a1c6762a1ea9bac3846 to your computer and use it in GitHub Desktop.
sub remove_and_prepend_path {
my $arr = shift;
my $path = shift;
my @backup;
while (@{$arr}) {
my $p = shift @{$arr};
unshift @backup, $p unless ($p eq $path);
}
unshift @{$arr}, shift @backup while (@backup);
unshift @{$arr}, $path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment