in reply to DIVIDING STRING IN TO WORD W/O USING SPLIT FUNCTION
Um... split uses a regexp. Are you saying you want to write a new function that works just like split, but has a different name? How about:
That's not exactly the same as "split", but it's pretty close. Anyway, it's not clear what your real goal is. I think that something like your second "example" could be done using split this way:sub sprit { return ( $_[1] =~ /(.*?)(?:$_[0]|$)/g ); }
my @pieces = split /(\s+)/, "hello, yes, I can see you need help."; print join( ":\n :", "split returned the following pieces", @pieces ), + ":\n";
|
|---|