#!/usr/bin/perl -w
# $Id: fib3.pl,v 1.1.1.1 2008/10/12 04:05:34 alamos Exp $

my($n) = @ARGV;
$n >= 2 || die $!;
@_=(1, 1);
# This implementation uses a range operator .. to construct 
# an array to iterate over. Should be less efficient
# than the explisit loop with a control variable
foreach (1..$n) {
    @_ = (@_, $_[-1] + $_[-2]);
}
print "Found ", scalar(@_), " elements of the Fibonacci sequence.\n";
print join(",",@_), "\n";
