http://qs321.pair.com?node_id=507401

emilford has asked for the wisdom of the Perl Monks concerning the following question:

I have a form with a couple of form fields that have a 4000 character limit. I put in place some JS code that fails form submission if any of the fields are 4001+.

The problem is that some strings that the JS code finds to be < 4000, Oracle does not and everything comes crashing down. I decided to throw in an extra check w/in my Perl code that does a substr($x, 0, 4000) on all values, just to double check.

The problem I found, however, the string that JS and wc think is 4000, Perl thinks is 4052. I'm assuming that this has something to do with line breaks, etc. Perl truncates the string down to what it thinks is 4000 characters, but it's actually hacking off a chunk of the user's input.

So, my question is in regard to matching up what JS and Oracle think is 4000 characters to what Perl thinks is 4000 characters. How do I get Perl to recognize this difference?