«...If you'd have tried it yourself you'd have had a yes/no answer in about the time it took to write your question and probably about 1/5th the time it took for you to see the first answer»
Nothing but the truth. But perhaps this has something to do with that you are Cardinal and the OP is Novice ;-)
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] |
deshdaaz asked if this code legal or no. Who knows maybe this code works but considered as dirty hack, or considered deprecated.
| [reply] |
«Who knows maybe this code works but considered as dirty hack, or considered deprecated.»
OK, so what?
But to bring this issue to a good end - another brother asked me already about it -here is the extended version of my private answer to him:
- I didn't want that the OP remains novice
- My post was marked as a joke
- Perhaps this joke wasn't so good
- I didn't want to annoy anybody
- There have been jokes around here worse than mine
- There have been questions around here worse than the OP's
My best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] |
Who knows maybe this code works but considered as dirty hack, or considered deprecated. :) I know. It is neither hack nor deprecated -- plenty of examples in the test suite and the docs
| [reply] |
Yes Sir, I did try and it did work. However my actual code goes through more than thousand files and I was not certain if it actually completed all three arrays or not hence the question. Sorry for the trouble. | [reply] |
From all the answers you got, the one from Athanasius was IMHO the best so far.
It's elementary for Perl that @arrays and %hashes are flattened in list context, not only in the case of a foreach (LIST), but whenever the docs talk about "LIST" as parameter.
from perldata#List value constructors
LISTs do automatic interpolation of sublists. That is, when a LIST is evaluated, each element of the list is evaluated in list context, and the resulting list value is interpolated into LIST just as if each individual element were a member of LIST. Thus arrays and hashes lose their identity in a LIST--the list
(@foo,@bar,&SomeSub,%glarch)
contains all the elements of @foo followed by all the elements of @bar, followed by all the elements returned by the subroutine named SomeSub called in list context, followed by the key/value pairs of %glarch.
for instance
DB<105> @a=1..3
=> (1, 2, 3)
DB<106> @b=a..c
=> ("a", "b", "c")
DB<107> @c=(@a,@b)
=> (1, 2, 3, "a", "b", "c")
HTH! =)
Cheers Rolf
( addicted to the Perl Programming Language)
| [reply] [d/l] [select] |
It was not "trouble", and actually not a bad question, but learning to write small test programs to check your understanding is a very useful art. The same art applies when the question grows beyond anything one can answer for oneself, but then the art morphs into being able to create a small focused test script that others can use as a test bed for understanding your issue and providing a solution.
True laziness is hard work
| [reply] |