Requiring the named arguments to be specified inside a hash ensures that any mismatch, such as:$line = padded({text=>$line, cols=>20..21, centered=>l, filler=>$SPACE});
will be reported (usually at compile time) in the caller's context:
Odd number of elements in anonymous hash at demo.pl line 42
Passing those arguments as raw pairs:
$line = padded(text=>$line, cols=>20..21, centered=>l, filler=>$SPACE);
would cause the exception to be thrown at run time, and from the line inside the subroutine where the odd number of arguments were unpacked and assigned to a hash:
Odd number of elements in hash assignment at Text/Manip.pm line 1876
The only difference in error handling that I can think of might result from unquoted keys ... (?)
Cheers Rolf
In reply to Re: Named Subroutine Parameters: Compile-time errors vs. Run-time warnings
by LanX
in thread Named Subroutine Parameters: Compile-time errors vs. Run-time warnings
by AnomalousMonk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |