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

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 3c1533 in the box below so that we can be sure you are a human.