Help for this page

Select Code to Download


  1. or download this
    my %hash = ((split / /, $str), $str =~ y/ / / % 2 ? () : undef);
    
  2. or download this
    $ perl -wMstrict -MData::Dump -e 'my $s = "a 1 b 2 c 3 Odd"; my %h = (
    +(split / /, $s), $s =~ y/ / / % 2 ? () : undef); dd \%h'
    { a => 1, b => 2, c => 3, Odd => undef }
    $ perl -wMstrict -MData::Dump -e 'my $s = "a 1 b 2 c 3 Even 4"; my %h 
    += ((split / /, $s), $s =~ y/ / / % 2 ? () : undef); dd \%h'
    { a => 1, b => 2, c => 3, Even => 4 }