develooper Front page | perl.perl5.porters | Postings from April 2000

Re: [ID 20000424.006] split() returning incorrect number of fields

Thread Previous
From:
Jeff Pinyan
Date:
April 24, 2000 15:00
Subject:
Re: [ID 20000424.006] split() returning incorrect number of fields
Message ID:
Pine.GSO.4.21.0004241758470.28375-100000@crusoe.crusoe.net
On Apr 24, Adam Moskowitz said:

>In the following program, I contend that split() should return the same
>number of fields in both cases:
>
>	my $str1 = "aaa:bbb:ccc:ddd:eee";
>	my $str2 = "aaa:bbb:ccc:ddd:";
>	@w = split(/:/, $str1);
>	@w = split(/:/, $str2);

>It doesn't. I'm pretty sure that this is neither the correct nor
>expected behavior.

  split /PATTERN/,EXPR,LIMIT

  split /PATTERN/,EXPR

  split /PATTERN/

  split

  Splits a string into an array of strings, and returns it.  By default,
  empty leading fields are preserved, and empty trailing ones are deleted.
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy@pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About