in reply to Filling a hash

In the sense of "having fun with homework questions" how about this? M-)

perl -MData::Dumper -ne '/^exit$/i&&die"Ok. I\x27m done".Dumper(\%h);chomp;$h{$_}=$_'

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^2: Filling a hash
by chester (Hermit) on Oct 26, 2005 at 16:41 UTC
    Here is another simple solution. Inputs are taken 2 per line, separated by ^Q for clarity's sake, ignoring malformed input.

    until (defined($flag) and defined($flag) == $flag) { ($_=substr(<STDIN>,0,-1)) !~ /\A^\be{1,1}\B(?=x(?=i(?=t)))\Bx{1,1} +\B(?=i(?=t))i(?=t)\Bt{1,1}\b\Z\z$/ and ((index($_,"\x11") == -1) or ($_{ substr($_,0,index($_,"\x +11")) } = substr($_,index($_,"\x11")+1))) or ($flag = print map {$_.$".$_{$_}.$/} keys %_) }