"be consistent" | |
PerlMonks |
Re: How to split a non even number of string elements into a hash - updateby Discipulus (Canon) |
on Feb 09, 2017 at 12:43 UTC ( [id://1181517]=note: print w/replies, xml ) | Need Help?? |
hello thanos1983, From my point of view what you are trying to achieve is simply wrong: hash are built of key - value pairs (where pair imply evenly) so why have something to over come something that must be true by definition? To populate an hash you must provide even elements and if there are possibilities that elements are odd you must workaround and end with an even list, as you are doing in the second example. PS: note also that the operation is always risky: the odd element must be the last one or the hash will be messed up. PPS if you want to ignore odd element you can do somthing like this:
the above was wrong, this no:
L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|