Obviously you didn't test before posting. There are syntax errors (missing curlies in your if-statements, see "Compound Statements" in
perldoc perlsyn), and you are still using the nonsensical assigning-shift-to-a-list (see
my previous comment about that). Please read
perldoc shift again.
I admit having posted untested code myself occasionally, but the section "cool uses" would imply to me, that you did use it, which would already be an (albeit very rudimentary) test.
And finally, I want to join in the general chorus "use strict and warnings!!!1!"