in reply to Popping from method that returns a list in one line

Hi, as you can see, it's usually best to return references to arrays and hashes from functions.

But what about

($fp->get_files)[-1]
?

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Popping from method that returns a list in one line
by AnomalousMonk (Archbishop) on Aug 29, 2019 at 00:13 UTC

    E.g.:

    c:\@Work\Perl\monks>perl -wMstrict -le "sub foo { return qw(foo bar baz quux); } ;; my $o = bless \do {my $x}; ;; my $like_as_if_it_was_popped = ($o->foo)[-1]; print $like_as_if_it_was_popped; " quux


    Give a man a fish:  <%-{-{-{-<