Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

by AnaximanderThales (Novice)
on Nov 18, 2014 at 19:27 UTC ( #1107620=note: print w/replies, xml ) Need Help??

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

No worries --

The issue that I'm having with the declarative width is how '7' is arrived (I use 7 now, but I'll clarify in a moment).

Since I'm wrapped up in trying to get my project in a state that I'm satisfied with right now so I haven't played with this more, so I can't say for certain this occurred.

We have {>>>>>} which is 7 characters. We have {>(5)>} which is also 7 characters? Okay -- I'll accept that the {} are included in the count. In my mind, while I was playing with things, I remember switching {>(5)>} to {>(3)>}. This should be 5 characters. When I have " 003," I should not get the validation error. My data has 5 characters, the field is 5 characters.

Like I said, I haven't gone back and tested it, it was one iteration out 20 or 30 tries. So, this is what I need to bang around with and figure out. I just need more experience with it, break what I'm doing, ask more questions and just get it set in my mind with my own words.

  • Comment on Re^4: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)

Replies are listed 'Best First'.
Re^5: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)
by Loops (Curate) on Nov 18, 2014 at 19:39 UTC

    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.

      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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2023-06-05 22:28 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.