#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $str = "one 1 two 2 three 3 odd_element"; my %hash = split / /, $str; print Dumper \%hash;