--- Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
> On Jun 21, Paul said:
>
> >--- Chuck Ivy <[EMAIL PROTECTED]> wrote:
> >> 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.
> >
> >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;
>
> Ewww. ;) First, you need the /s modifier on the regex. Second, you
> need
> the /g modifier on the regex. Third, you don't need the () in the
> regex.
>
> @chars = $str =~ /./gs;
>
> Fourth, split() is far nicer to look at.
>
> @chars = split //, $str;
>
> Fifth, just join() the elements you want.
>
> $str = join '', @chars[0 .. 4095];
>
> Sixth, get rid of the array.
>
> $str = join '', (split //, $str)[0 .. 4095];
>
> But we're not using this approach anyway, are we? ;)
LOL -- what he said. =o)
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/