<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thank you Gaal!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Once again, I constantly forget the RTFM directive. ‘split’ (and ‘join’) are so intuitive that I never bothered to lookup the doc.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thank all of you<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Meir<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> perl-bounces@perl.org.il [mailto:perl-bounces@perl.org.il] <b>On Behalf Of </b>Gaal Yahas<br><b>Sent:</b> </span><span lang=HE dir=RTL style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>יום&nbsp;ב 04 מרץ 2013 15:35</span><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'><br><b>To:</b> Perl in Israel<br><b>Subject:</b> Re: [Israel.pm] Inconsistent 'split' behavior<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><o:p>&nbsp;</o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt'>Try split /\t/, $str, -1. See perldoc -f split for more details.<o:p></o:p></p><div><p class=MsoNormal style='margin-left:36.0pt'>On Mon, Mar 4, 2013 at 2:32 PM, Meir Guttman &lt;<a href="mailto:meir@guttman.co.il" target="_blank">meir@guttman.co.il</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal style='margin-left:36.0pt'>Hello Perlers.<br>I recently discovered what seems to me an inconsistent behavior when<br>splitting Tab-separated-Values (TSV). If the last column has an empty<br>string, no empty string is added to the 'split' array. However, when a<br>center column has an empty string (simply two consecutive tab-characters) it<br>is conserved.<br>Is that behavior as it should be?<br>Here is a small script to show it:<br><br>use strict;<br>use warnings;<br>use Data::Dumper::AutoEncode; # This one supports Unicode<br><br>my $tsv_line = &quot;col_1\tcol_2\tcol_3&quot;;<br>print &quot;Regular TSV string: '$tsv_line'\n&quot;;<br>my @split_line = split(&quot;\t&quot;, $tsv_line);<br>print eDumper(\@split_line), &quot;\n&quot;;<br><br>my $missing_col_tsv_line = &quot;col_1\tcol_2\t&quot;;<br>print &quot;missing LAST column TSV string: '$missing_col_tsv_line'\n&quot;;<br>my @split_missing_col_line = split(&quot;\t&quot;, $missing_col_tsv_line);<br>print eDumper(\@split_missing_col_line), &quot;\n&quot;;<br><br>my $missing_middle_col = &quot;col_1\t\tcol_3&quot;;<br>print &quot;missing MIDDLE column TSV string: '$missing_middle_col'\n&quot;;<br>my @split_missing_middle_col = split(&quot;\t&quot;, $missing_middle_col);<br>print eDumper(\@split_missing_middle_col), &quot;\n&quot;;<br><br>Meir<br><br>_______________________________________________<br>Perl mailing list<br><a href="mailto:Perl@perl.org.il">Perl@perl.org.il</a><br><a href="http://mail.perl.org.il/mailman/listinfo/perl" target="_blank">http://mail.perl.org.il/mailman/listinfo/perl</a><o:p></o:p></p></div><p class=MsoNormal style='margin-left:36.0pt'><br><br clear=all><o:p></o:p></p><div><p class=MsoNormal style='margin-left:36.0pt'><o:p>&nbsp;</o:p></p></div><p class=MsoNormal style='margin-left:36.0pt'>-- <br>Gaal Yahas &lt;<a href="mailto:gaal@forum2.org">gaal@forum2.org</a>&gt;<br><a href="http://gaal.livejournal.com/">http://gaal.livejournal.com/</a> <o:p></o:p></p></div></div></body></html>