#!/usr/bin/perl @hits = (-1,1); for(1..10){ print toggle(),"\n"; } sub toggle{ push (@hits,shift(@hits)); return $hits[0]; }