New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perldoc -f split lacks basic null example #7748
Comments
From @jidanniLet's say we want to split on each character. We do perldoc -f split: A pattern matching the null string (not to be confused with a null print join(':', split(/ */, 'hi there')); produces the output 'h:i:t:h:e:r:e'. Using the empty pattern "//" specifically matches the null string, By now the beginner is thoroughly frightened about the best way to Apparently // and '' are both work. Anyway, the best choice should be print join(':', split('', 'hi there')); produces the output 'h:i: :t:h:e:r:e'. Otherwise we jump into the deep end of the swimming pool straight to |
From @ysthOn Tue, Jan 11, 2005 at 10:22:43PM -0000, Dan Jacobson wrote:
Perhaps you'd like to take a look at |
The RT System itself - Status changed from 'new' to 'open' |
From @jidanniD> Perhaps you'd like to take a look at |
From @smpeters
I'd rather they decide the way that they prefer to split. Below is a Inline Patch--- pod/perlfunc.pod.old Tue May 3 07:46:43 2005
+++ pod/perlfunc.pod Wed May 11 12:09:22 2005
@@ -5079,7 +5079,13 @@
Using the empty pattern C<//> specifically matches the null string, and is
not be confused with the use of C<//> to mean "the last successful pattern
-match".
+match". So, for C<split>, the following are equivolent:
+
+ print join(':', split(//, 'hi there'));
+
+ print join(':', split('', 'hi there'));
+
+and they produce the output 'h:i: :t:h:e:r:e'.
Empty leading (or trailing) fields are produced when there are positive
width
matches at the beginning (or end) of the string; a zero-width match at the |
From ams@wiw.orgAt 2005-05-11 17:13:29 -0000, perlbug-followup@perl.org wrote:
Thanks, applied. (#24449) -- ams |
From @pjcjOn Wed, May 11, 2005 at 05:13:29PM -0000, Steve Peters via RT wrote:
s/equivolent/equivalent/ -- |
From @tamiasOn Wed, May 11, 2005 at 05:13:29PM -0000, Steve Peters via RT wrote:
I don't understand the point of this patch. The text implies that split(//) and split('') are equivalent because // Of course split('') is equivalent to split(//), just as split('a|b') is Ronald |
From @iabynOn Wed, May 11, 2005 at 02:14:28PM -0400, Ronald J Kimball wrote:
And of course split(/a\b/) is *not* equivalent to split("a\b"), so it's -- |
From RandyS@ThePierianSpring.orgDave Mitchell wrote:
Similar discussion here several years ago set me against ever using It would've been nice if split(undef,...) could have been used as a Randy. |
From @rgsRandy W. Sims wrote:
I concur (and I even tried to add a warning about this. Too noisy, though) I thus applied this : ==== //depot/perl/pod/perlfunc.pod#468 (text) ==== @@ -5077,15 +5077,14 @@ produces the output 'h:i:t:h:e:r:e'. -Using the empty pattern C<//> specifically matches the null string, and is print join(':', split(//, 'hi there')); - print join(':', split('', 'hi there')); Empty leading (or trailing) fields are produced when there are positive |
@smpeters - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#33766 (status was 'resolved')
Searchable as RT33766$
The text was updated successfully, but these errors were encountered: