sub padded {
my ($text, $arg_ref) = @_;
# Set defaults...
# If option given... Use option Else default
my $cols = exists $arg_ref->{cols} ? $arg_ref->{cols} : $DEF_PAGE_WIDTH;
my $filler = exists $arg_ref->{filler} ? $arg_ref-> : $SPACE;
# ... etc
return $filler x $left . $text . $filler x $right;
}
####
sub unpack_named_first {
my ($pos1, $pos2 ,%arg) = @_; # unpack
my ($name1, $name2) = @arg{'name1','name2'}
$pos1 // die("Missing arg!"); # obligatory
$pos2 //= 42; # default
$name1 // die("Missing arg!"); # obligatory
#$name2 # optional
# ...etc
}
####
sub unpack_named_later {
my ($pos1 ,$pos2 ,%arg) = @_;
$pos1 // die("Missing arg!");
$pos2 //= 42;
$arg{name1} // die("Missing arg!");
# if you need to unpack hash-args
my ($name1,$name2) = @arg{qw/name1 name2/};
# ...etc
}
####
sub unpack_named_on_the_fly {
my ($pos1 ,$pos2 ,%arg) = @_;
$pos1 // die("Missing arg!");
$pos2 //= 42;
my $name1 = $arg{name1} // die("Missing arg!");
my $name2 = $arg{name2};
# ...etc
}
####
$pos1 // die_miss();
$pos2 // warn_miss();