On Jul 26, 3:22 am, sharan.basa...@gmail.com (Sharan Basappa) wrote: > Hi, > > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the element in the > array row as the key. > e.g. hash{ab} = cd ef - ab is a string in the array row > hash{mn} = de fg - mn is a string in the array row >
my %hash = map { split / ^ \S+ \K [ ]+ /x, $_ } @a; See \K in perlre (5.10 or greater) also perldoc -f split, perldoc -f map -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/