Hi dZ,

According to documentation, the prototype of split has a third parameter:

split /PATTERN/, EXPR, LIMIT

If LIMIT is omitted in the function call, then "trailing null fields are 
stripped from the result", as the Camel book states. I also stumbled on it a 
few times...

 -- Andreas

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von DZ-Jay
Gesendet: Montag, 5. Dezember 2005 13:59
An: perl-win32-users@listserv.ActiveState.com
Betreff: split() skipping trailing delimiters

Hello:
        I have a problem using the split() function:  When there are trailing
delimiters, without any content between them, split() skips them.  For
example, this:

        my @foo = split(/,/, 'this,is,a,test,,');

yields:
        this
        is
        a
        test

while I'm expecting:
        this
        is
        a
        test
        ''
        ''

Is there any way around this? I need to split strings on a specific
delimiter and detect all null fields within the string, including
trailing ones.

        Thanks in advance!
        dZ.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


****************************************************************************************

Note:  If the reader of this message is not the intended recipient, or an 
employee or agent responsible for delivering this message to the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this communication is strictly prohibited. If you have received this 
communication in error, please notify us immediately by replying to the message 
and deleting it from your computer. Thank you.

****************************************************************************************

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to