Crossposted to
StackOverflow. It's OK to crosspost, but it's considered polite to inform about crossposting to prevent people not attending both sites from spending time on a solution of a problem already solved at the other end of the internets.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]