in reply to Re: code to get the first line of an array
in thread code to get the first line of an array

..or
my ( $first_line ) = @array;

This works by the fact that the parenthesis denote a list, and you're copying the elements of the array into the elements in the list (of which there is just one in this example). This is non-destructive to the array.

You can also view the second and third lines and soforth by continuing with this notion:

my ( $first, $second, $third ) = @array;

This is a technique I regularly use when parsing parameters passed to a function. The function parameters are placed in @_ and so I write:

sub myfunction( $ $ $ ) { my ( $param1, $param2, $param3 ) = @_; # ... }