in reply to "shift" not working as expected

This ...

> The expected result is : 0

... and this ...

> return if not $data;

... collide, because 0 is false in Perl.

You want to try defined or even better just check the size of @arrX °

BTW: This code looks weird, what's your real intention?

HTH! =)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

update

°)... e.g. like in return unless @arrX

... which is very Perlish, boolean context is subcase of scalar context which returns the size.

And as we know now that 0 is false ;-)

Replies are listed 'Best First'.
Re^2: "shift" not working as expected
by ForeverLearning (Novice) on Mar 20, 2016 at 16:13 UTC
    Hi Lanx,

    Thanks for your reply. Regarding my "weird code", the underlying concept is the "Throttle" example from this AnyEvent::HTTP tutorial (http://perlmaven.com/fetching-several-web-pages-in-parallel-using-anyevent).

    If you think that way of doing things is weird, do let me know ! I don't want to do weird stuff that might come and bite me in the backside later !

Re^2: "shift" not working as expected
by ForeverLearning (Novice) on Mar 20, 2016 at 16:21 UTC
    Perhaps to clarify my "real intention" even further than my previous reply, I'm planning to loop through an array of offset counts so that I can use AnyHTTP to upload blocks of a large file to a REST API in parrallel.
      Unfortunately I'm not qualified to talk about AnyEvent et. al.

      Your code looked strange because of all the closures, but in the case of defining simultaneous call backs this looks like the way to go. :)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!