Crossposted to
StackOverflow. It's considered polite to inform about crossposting to protect people not visiting both sites from unnecessary work of hacking a solution to a problem already solved at the other end of the internet.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]