LPM: regexp question
Rich Bowen
rbowen at rcbowen.com
Tue Dec 21 09:35:24 CST 1999
llang at baywestpaper.com wrote:
>
...
> I've been playing with the numeric as the third argument to split because
> I've never seen it before. My book has no mention of it. (Guess I need a
> bigger book ;-) )
>
> $sent="This is a test of the first five words.";
> @s=split(/ /,$sent,5);
> foreach (@s) {print;print"\n";}
>
> yields
>
> This
> is
> a
> test
> of the first five words.
>
> The fifth element has everything from that point on. (Might be a Win32-ism
> versus other platforms, but I can't see why...)
> So it should be pretty quick to change it to 6 and pop the last one off, no
> matter what the size of $sent. Or am I shootin' blanks?
Bah. That's what I get for not testing code before I send it out.
No, that's right. It should be changed to 6. The argument basically
means 'split it into this many pieces'.
Rich
--
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt
More information about the Lexington-pm
mailing list