[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] From "The Art of Perl", Ch. 1



I'm looking for some idioms for dealing with arrays, hashes, and unnamed
lists.  For more information on "The Art of Perl", visit:

	http://magneton-59.dynamic.rpi.edu/book/

Submissions I incorporate will be acknowledged.


Operating on Lists
------------------

array-to-hash

	while (($k,$v) = each %{{ @list }}){ ... }
	while ($i < @list){ ($k,$v) = @list[$i++,$i++]; ... }

slicing

	@list = (somefunc())[1,4,6..9];

hash things

	@uniq{@list} = ();
	keys %{{ @tmp{@list} = () or %tmp }};


I'd like some more ideas for idioms.  Some of them might be ones no one
else has seen (I doubt anyone has used that last idiom I put up there).
There are many commonly known ones that I've not put up on this list, but
mention them as well, just in case.

If this isn't a suitable application of the FWP forum, let me know.  I
thought some of these idioms, and the task of finding/making ones would be
fun... with Perl.

-- 
jeff pinyan    japhy@pobox.com
perl stuff     japhy+perl@pobox.com
CPAN ID: PINYAN            http://www.perl.com/CPAN/authors/id/P/PI/PINYAN


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe