while (@paths) { $where = ($where->{shift @paths} ||= {}); } print Dumper($where);