while (@todos) { my $todo = pop @todos; print "id: ", $todo->{data}{id}, "\n"; splice(@{$todo->{data}},0,1) if ($todo->{data}{id} =~ /^2$/);