in reply to Best way(s) to process form data into fixed-length values?

I think you are correct in pursuing sprintf as one good way to skin this cat. But I must admit, I personally prefer working with delimited records to fixed-length records any day of the week. Are you sure you can't do this with a delimiter, rather than fixed-length?

If you decide you must use a fixed-length strategy, you might try declaring a hash with attribute names and expected string length (or other formatting instructions). Then you could pass each form input to a standard write_me() routine that would look up the appropriate formatting instruction and write it out to your file (or whatever).

I'm sure there are lots of TIMTOWTDI variations. :)


No good deed goes unpunished. -- (attributed to) Oscar Wilde
  • Comment on Re: Best way(s) to process form data into fixed-length values?

Replies are listed 'Best First'.
Re^2: Best way(s) to process form data into fixed-length values?
by hmbscully (Scribe) on Jul 25, 2006 at 20:23 UTC
    The fixed-length issue is a requirement from the client. They're defining the file format, i just have to deal with it. I too prefer delimited. I personally love |.
    Thanks for the suggestions.

    I learn more and more about less and less until eventually I know everything about nothing.