in reply to How to split a non even number of string elements into a hash [RESOLVED]

TMTOWTDI, although certainly not best way. :P
my $str = "one 1 two 2 three 3 odd_element"; my $cnt = () = $str =~ /(\s)/g; # count spaces my %hash = split /\s/, $str, $cnt + 1; # split on spaces + 1
  • Comment on Re: How to split a non even number of string elements into a hash [RESOLVED]
  • Download Code

Replies are listed 'Best First'.
Re^2: How to split a non even number of string elements into a hash [RESOLVED]
by thanos1983 (Parson) on Feb 10, 2017 at 12:05 UTC

    Hello Anonymous Monk,

    Some times even the worst solutions can be proven great if they work.

    Maybe not the best but another way to resolve it. :D Thanks for your time and effort.

    Seeking for Perl wisdom...on the process of learning...not there...yet!