Keep It Simple, Stupid | |
PerlMonks |
Re: Declaring with my, assigning, and testing in same line (custom routine)by LanX (Saint) |
on Dec 12, 2015 at 03:17 UTC ( [id://1150090]=note: print w/replies, xml ) | Need Help?? |
First this behaviour is well documented in perlsub ¹ And if it's not a frequent use case, please use two lines. The next maintainer will be thankful to easily read how @v is defined:
Otherwise if you really need it that often, why don't you simply define a helper function?
And if you need more flexibility in testing, use some functional magic
but again, for the sake of readability please use a line break (even if it's a one liner)
And for completeness , I'm sure you could also use variable :attributes for such checks. my @v :check = keys %h; See Attribute::Handlers for details.
Cheers Rolf
¹)
In Section
Seekers of Perl Wisdom
|
|