#!/usr/bin/perl -w
use strict;

sub fib {   # write Fibonacci series up to n
    my ($n) = @_;
    my @result;
    my ($a, $b) = (0, 1);
    while($b < $n) {
        push(@result,$b);
        ($a, $b) = ($b, $a+$b);
    }
    return @result;
}

print join(" ",&fib(10)),"\n";
