Perl (Scripting) - Remove first element from array (splice)

by
Jeremy Canfield |
Updated: March 23 2021
| Perl (Scripting) articles
Let's say you have multple lines of data in an array
my @foo = qw(
line 1
line 2
line 3
);
You can print the array.
print @foo;
And all of the lines will be printed.
line 1
line 2
line 3
Splice can be used to remove the first line from the array.
splice (@foo, 0, 1);
Now when you print the array, line 1 has been removed.
line 2
line 3
Did you find this article helpful?
If so, consider buying me a coffee over at