develooper Front page | perl.perl5.porters | Postings from November 2005

strange split feature

Thread Next
From:
Torsten Foertsch
Date:
November 29, 2005 02:16
Subject:
strange split feature
Message ID:
200511291115.46830.torsten.foertsch@gmx.net
Hi,

perl -MData::Dumper -e 'print Dumper( [split /:/, ":a::b::"] )'
$VAR1 = [
          '',
          'a',
          '',
          'b'
        ];

I would expect the list to contain just another 2 empty strings as the last 
elements.

perl -MData::Dumper -e 'print Dumper( [split /(:)/, ":a::b::"] )'
$VAR1 = [
          '',
          ':',
          'a',
          ':',
          '',
          ':',
          'b',
          ':',
          '',
          ':'
        ];

This is almost what I would expect. But again I miss the last empty string.

This is 5.8.5.

Torsten

Thread Next


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