#!/usr/bin/perl -w use strict; use Tie::Cycle; tie my $cycle, 'Tie::Cycle', [0,1,2,3]; for(1..7){ print $cycle, " "; } # printed thus far: 0 1 2 3 0 1 2 print "\n", '-' x 10, "\n"; # logical OR returns left expression if TRUE otherwise right # expression: my ($x,$y) = (0,42); my $z; $z = $x || $y; print "\$z is $z\n"; # prints: $z is 42 (as expected) $z = $y || $x; print "\$z is $z\n"; # prints: $z is 42 (as expected) print '-' x 10,"\n"; # next use of $cycle should get 3: my $ook = $cycle || 42; print "\$ook is $ook\n"; # prints: $ook is 0