in reply to Re^2: What is Perl way to simultaneously assign to three separate arrays?
in thread What is Perl way to simultaneously assign to three separate arrays?

> I'd like to know if everything can be done in a single assignment without any munging afterward.)

No, you are using /g in list context which swallows the whole file now and returns a flat list.

You need an external loop to process the 3 groups

update

With a post while you can have the loop in the same line

 push @res, [ $1,$2,$3 ] while m/.../g

In the OP you were originally looping with $_ , that's confusing.

you should rather be concerned about maintainability than shortness.

Cheers Rolf

PS: Je suis Charlie!

  • Comment on Re^3: What is Perl way to simultaneously assign to three separate arrays?
  • Download Code

Replies are listed 'Best First'.
Re^4: What is Perl way to simultaneously assign to three separate arrays?
by CoVAX (Beadle) on Feb 15, 2015 at 20:40 UTC
    you should rather be concerned about maintainability than shortness.

    Agreed.

    Still, I am fascinated by idiomatic Perl and its myriad other ways of doing something (the Schwartzian Transform comes to mind).

    Searched for donut and crumpit. Found donate and stumbit instead.