#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';

my $last1 = 0;
my $last2 = 1;
my @fib = ($last1, $last2);
while (@fib < 40){
    @fib = (@fib, $last1 + $last2);
    my $temp = $last1 + $last2;
    $last1 = $last2;
    $last2 = $temp;
}
while (@fib){
    print shift @fib, " ";
}
print "\n"
