Tuesday, July 28, 2009

What does split return in PERL if the field is left blank?

If you have a line: aa|bb|cc||dd





and use the split function, it will return





string[0] = aa


string[1] = bb


string[2] = cc


string[3] = ?


string[4] = dd





What is the character representation for string[3]?

What does split return in PERL if the field is left blank?
Why don't you try it and see for yourself???





use Data::Dumper;


my $s = '|aa|bb|cc||dd|';


my @as = split(qr{\|}, $s);


print Dumper(\@as);


No comments:

Post a Comment