Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Popping from method that returns a list in one line

by jcb (Parson)
on Aug 28, 2019 at 23:44 UTC ( [id://11105200]=note: print w/replies, xml ) Need Help??


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

You cannot pop the return value of ->get_files because it is not an array.

pop @{[$fp->get_files]}

That should work, but should make the uselessness of this obvious: it constructs an array from the list returned by ->get_files, removes the last value from that array, and then throws the entire array away.

If this is part of File::Collector, I do not see a way for ->get_files to do what you seem to want, although you could add a ->get_file_queue method that returns a reference to the current file queue for a category. If I understand correctly, this would be return $s->{"_iterator_$type"} (but you should probably change your instance variables to make that return $s->{iterators}{$type} instead).

Replies are listed 'Best First'.
Re^2: Popping from method that returns a list in one line
by BillKSmith (Monsignor) on Aug 29, 2019 at 16:03 UTC
    You cannot pop the return value of ->get_files because it is not an array.

    For an explanation of why this makes a difference, see the FAQ:

    perldoc -q "What is the difference between a list and an array"

    The Synopsis section of the documentation pop specifies that it requires an array.

    Bill
Re^2: Popping from method that returns a list in one line
by nysus (Parson) on Aug 28, 2019 at 23:58 UTC

    Thanks. I was just writing a quick and dirty test for the module and ran across this issue.

    ok $fp->get_data(pop @{($fp->get_parseable_files)}), 'can get data from file';

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      which prolly should be

      ok $fp->get_data(pop @{[$fp->get_parseable_files]}), 'can get data fro +m file';
      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Or maybe (untested):
          ok $fp->get_data(($fp->get_parseable_files)[-1]), 'can get data from file';


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105200]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-20 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found