Help for this page

Select Code to Download


  1. or download this
    my $str = "this,ok,that,cool,free,dom";
    for my $key (sort keys (%hash = split /,/, $str)) {
      ...
    }
    
  2. or download this
    for my $key (sort keys %{ $hashref = { split /,/, $str } }) {
      ...
    }
    
  3. or download this
    for my $key (sort keys %{ +{%hash = split /,/, $str} }) {
      ...
    }
    
  4. or download this
    for my $pair (sort($str =~ /([^,]*,[^,]*)(?:,|$)/g)) {
      my ($k, $v) = split /,/, $pair;
      ...
    }