Couldnt you do something like<br><br>for (@data)<br>{<br>&nbsp;&nbsp;&nbsp; $_ =~ s/\s+/g;<br>}<br><br>or <br><br>my @newdata;<br><br>for (@data)<br>{<br>&nbsp;&nbsp;&nbsp; s/\s+/g;<br>&nbsp;&nbsp;&nbsp; push @newdata, $_;<br>}<br><br>I haven&#39;t tested, but both should work. <br>
<br>How was the tech meeting on Wednesday? $Work is usurping all my time :(<br><br>Ted<br><div class="gmail_quote">On Thu, Apr 3, 2008 at 8:39 PM, Faber J. Fedor &lt;<a href="mailto:faber@linuxnj.com">faber@linuxnj.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I&#39;m reading in a CSV file line by line. &nbsp;I need to trim leading and<br>
trailing whitespace out of each comma-delimited field. So I figured I&#39;d<br>
use map an enclosure like so:<br>
<br>
 &nbsp; &nbsp;my @data = split(/,/, $_);<br>
<br>
 &nbsp; &nbsp;map &nbsp;{ &nbsp; &nbsp; $_ =&gt; &nbsp;s/^\s+//;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_ =&gt; &nbsp;s/\s+$//;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} @data;<br>
<br>
 &nbsp; &nbsp;($sku,$warehouse,$quantity,$row,$product_type,$stack_location,$price)<br>
 &nbsp; &nbsp;= @data ;<br>
<br>
<br>
Two things I don&#39;t understand:<br>
<br>
1) why is map editing my array in place? &nbsp;It&#39;s supposed to return an<br>
array. &nbsp;The array it does return has extra empty data elements in<br>
between each original element.<br>
<br>
2. &nbsp;Why do I get a &quot;Useless use of a variable in void context at<br>
at_test.pl line 19.&quot; (line 19 being the line map is on)?<br>
<br>
Is there a better way of stripping the data?<br>
<br>
<br>
<br>
--<br>
<br>
Regards,<br>
<br>
Faber Fedor<br>
President<br>
Linux New Jersey, Inc.<br>
908-320-0357<br>
800-706-0701<br>
<br>
<a href="http://www.linuxnj.com" target="_blank">http://www.linuxnj.com</a><br>
<br>
<br>
<br>
<br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
_______________________________________________<br>
ABE-pm mailing list<br>
<a href="mailto:ABE-pm@pm.org">ABE-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/abe-pm" target="_blank">http://mail.pm.org/mailman/listinfo/abe-pm</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>When I do good, I feel good; when I do bad, I feel bad, and that is my religion.<br> - Abraham Lincoln