Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^5: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)

by Loops (Curate)
on Nov 18, 2014 at 19:39 UTC ( #1107624=note: print w/replies, xml ) Need Help??

in reply to Re^4: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)
in thread Perl6::Form Issues with Zero-Padding and Declarative Width

Ah, I see the source of confusion. I think you're mixing up Imperative field widths with what you're using, Declarative field widths.

Here's another field specification example to make things clear:


That is a field of 20 characters. That's the actual specification, no "(20)" in there at all. Adding the "(20)" doesn't change the width at all.. if you put in a "(7)" it wouldn't change the width either. But when the form is validated, the first one would pass, and the second would generate an error. This has nothing to do with _setting_ the width of the field, only validating that you've typed it in correctly with no missing or added characters.

Now if you don't want to type all those characters you can use the Imperative field width syntax using curly brackets:


This forces the field width to be 20 characters wide, so it is another way that has duplicate functionality to the first example.


Replies are listed 'Best First'.
Re^6: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)
by AnaximanderThales (Novice) on Nov 18, 2014 at 23:07 UTC
    I believe it makes sense now.

    {>(20)>} generates an error because it's not {>>>>>>>>>(20)>>>>>>>>>}?

    {>>>(7)>>} doesn't generate an error?

    The Parens'd value is a validity of the bracketed field as opposed to the value that will be presented at run time? Am I correct?

      Well, you could easily test that theory yourself. ;o) But unfortunately no. You must not insert the (7) into the format, you must overwrite existing characters instead.

      Step 1: Write the format you want.


      Step 2: Force Perl6::Form to validate the format length at runtime.


      In both cases above the string length is identical before and after the addition of this validation number.

      And really, most of the time you should just skip step 2. It doesn't buy you much. You can check these things with a decent text editor. As the author said, it was primarily meant for use by automated tools.

        I am a step closer on it, though! When I get home, I'll play around with it extensively. I'm still at work and have homework to tend to. I'll check in when I think I can explain it to someone with no background in it.

        Truly appreciate the time.

        Thank you.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1107624]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-08-19 05:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found