in reply to split and sort functions

Perhaps you don't want a hash at all. Or perhaps you want to do something with the elements in their original order before you build a hash. In either case, start by extracting all the pairs, then splitting them into their components. Then do whatever you're going to do with them (including, perhaps, inserting them in a hash).
use strict; use warnings; my $str='1,zxc,2,asd,3,qwe'; foreach ( $str =~ /([^,]+,[^,]+)/g ) { my ($k, $v) = split /,/; print "Do something with key $k and value $v\n"; }
Update:
I had a "duh" moment. You can, of course, extract the elements like so:
foreach (my ($k,$v) = $str =~ /([^,]+),([^,]+)/g) {

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: split and sort functions
by zkeeper (Initiate) on Apr 21, 2006 at 21:47 UTC
    Thank you all for answers. I realy don't need hash :). Regards, Alexander.