Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: Merge 2 strings like a zip [unzip()]

by tel2 (Pilgrim)
on Jul 10, 2015 at 00:39 UTC ( [id://1134066]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Merge 2 strings like a zip [unzip()]
in thread Merge 2 strings like a zip

Thanks for that explanation, Ken.

I was aware of what "print for..." does (though I didn't realise some of the finer points you've mentioned), but I asked because I thought your code also worked without the 'for'.  I now notice that the output without the 'for' has no newline between the returned arguments, i.e.:
   ABCDEFGHIJabcde
which I assume is because it's just printing the 2 arguments (like a list) together.

All that makes sense now though (I think), thanks.

Sorry I wasn't clearer with my last question.

Replies are listed 'Best First'.
Re^6: Merge 2 strings like a zip [unzip()]
by kcott (Archbishop) on Jul 10, 2015 at 04:35 UTC

    No worries. And, yes, your assumption is correct. Alternatives might be

    print join "\n", unzip('AaBbCcDdEeFGHIJ', 5);

    or the completely mad and hairy

    { local $" = "\n"; print "@{[unzip('AaBbCcDdEeFGHIJ', 5)]}"; }

    which, of course, you'd never consider doing, would you? :-)

    -- Ken

      Thanks Ken.

      Correct - I would not do that.  I does my head in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-19 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found