programming-examples/perl/Subroutine/Passing different number of parameter to a subroutine.pl
2019-11-15 12:59:38 +01:00

14 lines
259 B
Perl

#!/usr/bin/perl -w
use strict;
log_warning("A", "B");
log_warning("C");
log_warning();
sub log_warning {
my $message = shift || "Something's wrong";
my $time = shift || localtime; # Default to now.
print "[$time] $message\n";
}