--- Chuck Ivy <[EMAIL PROTECTED]> wrote:
> I've got a simple message board script that I cobbled together. It
> seems to have been the target of some abuse, though.
> 
> The latest patch I'd like to apply to the code would be limiting the 
> length of a message posted to, say, 4096 characters.
> 
> Now, looking up the substring function, it looks like if the original
> 
> string were less than the size of my substring, it would pad my
> variable 
> until it was 4096 characters.
> 
> Would a regex be better? Matching for up to 4096 characters and 
> replacing the string with $1?
> 
> I recall some programming languages treat strings as arrays of 
> characters. Is there a quick perl function or variable that
> represents 
> the length of a string? I didn't see any obvious entries in the index
> of 
> Programming Perl, but I may have been looking in the wrong place.
> 
> Or is this a good place for formatting commands?
> 
> Any suggestions welcome.

I'd agree with Japhy's substring suggestion, but I think you could do
something like this if you just wanted to play array games with the
string:

 @str = $str =~ /(.)/;
 $#str = 4095;
 $str = join '', @str;

Hey, TMTOWTDI, though you shouldn't overDO it.... =o)

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to