#!/usr/bin/perl use strict; use warnings; my $baz = 0; my $foo = shift; $foo = 1 if !defined($foo); chomp(my @bar = qw( etc etcetera )); die if $foo < 1; while($baz < $foo){ $baz += 1; print "$bar[rand @bar] ", "ad infinitum\n"; }