Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plain function

#use v5.44;
use feature 'say';
#use strict;
#use warnings;

sub area {
    my ($width, $height) = @_;
    return $width * $height;
}

my $area = area(2, 3);
say $area;

my $too_few = area(2);
say $too_few;

my $too_many = area(2, 5, 21);
say $too_many;

  • We have use feature 'say'; to add the say function without enabling any other feature. Nothing is reported.
  • We can turn on use strict; and use warnings;. The latter will generate a warning.
  • Alternatively it is enough to write use v5.44; and it turn on all the feautes.