perl function pop

The pop function in Perl removes and returns the last element from an array.

Here's an example:

my @numbers = (1, 2, 3, 4, 5);
my $last_number = pop @numbers;

print "Removed element: $last_number\n";
print "Remaining array: @numbers\n";
Sour‮w:ec‬ww.theitroad.com

Output:

Removed element: 5
Remaining array: 1 2 3 4

In this example, the pop function removes the last element (5) from the @numbers array and returns it. The value of $last_number is then printed to the console. The @numbers array now contains only the remaining elements (1, 2, 3, and 4). The remaining elements of the array are then printed to the console using the print statement.