Exercise: removing redundancy
Week 05 lab solution has some copy-and-paste:
@lines = <>;
$first = @lines - $max;
$first = 0 if $first < 0;
print @lines[$first..$#lines];
... and ...
@lines = <F>;
$first = @lines - $max;
$first = 0 if $first < 0;
print @lines[$first..$#lines];
|
This should be handled by a function.
How to call the function? What return value?
How to create a Perl function with file handle parameter?
|