![]() |
|
Think about Loose Coupling | |
PerlMonks |
Re^2: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)by AnaximanderThales (Novice) |
on Nov 18, 2014 at 13:46 UTC ( #1107570=note: print w/replies, xml ) | Need Help?? |
Yes, having received an email back from Damian (creator/maintainer of Perl6::Form), it was completely usage issues. For the zero-padding, you have everything mentioned. I was using it incorrectly based on your response. My issue with the float zero-padding was just the symantics. I had {0>>>.>>0} and the correcte usage is {0>>>.<<0} notice the change from > to < at the decimal point Additionally, as AM said, there is no INT padding, so the lfill (or rfill) is the correct method. I'm still a little confused by Damian's response on the Declarative Width ({<(5)<}), but I'm working on figuring it out. ME:The length give by perl shows that the field is actually 5 positions.Damian:No. The length of the *data* for the field is 5. :-) The *field* is the specification "{>(5)>}", which is definitely 7 characters in width (and hence invalid, since the "(5)" specifies that the surrounding field must be 5 characters wide. In other words, declarative field widths are not about validating the data to be interpolated; they are about checking that the field specification itself is consistent. In practice, declarative field widths are mostly only used for formats that have been autogenerated, as a way of checking that the field you somehow constructed is the correct width. They are not in any way about verifying the data to be formatted into a field. In fact, form() has no features for validating the data it formats. It just does its best to accommodate whatever data you through at it.ME:I'm curious as to why perl would say $tID is length 5 but form would say $tID is length 7.Damian:That's the misunderstanding in a nutshell. form() isn't saying the contents of $tID is of length 7; it's saying that the specifier for the "{>(5)>}" field into which $tID is being formatted is of length 7. I'm mulling Damian's definition about how the declarative width field operates. It's kind of making my head swim at the moment. I'll bang away on it until that little 1/16" turn makes it slip into place in my mind. I appreciate all the answers, and Damian's response. Thank you. @
In Section
Seekers of Perl Wisdom
|
|