```{index} single: tail; List::Util function ``` ```{index} single: List::Util::tail; Perl function ``` # tail Return the last `$size` elements of a list. ## Synopsis ```perl my @last = tail $size, @list; my @last = tail 2, qw( foo bar baz ); # ('bar', 'baz') ``` ## What you get back A list of at most `$size` elements, taken from the end of the input. If `$size` is negative, `tail` returns all but the first `-$size` elements — useful for dropping a head. ## Examples ```perl my @r = tail 2, qw( foo bar baz ); # ('bar', 'baz') my @r = tail -2, qw( foo bar baz ); # ('baz') my @r = tail 5, qw( a b c ); # ('a', 'b', 'c') — fewer than $size ``` ## Differences from upstream Fully compatible with upstream. ## See also - `head` — mirror operation, taking from the start. - `sample` — random selection without positional bias.