Couldnt you do something like<br><br>for (@data)<br>{<br> $_ =~ s/\s+/g;<br>}<br><br>or <br><br>my @newdata;<br><br>for (@data)<br>{<br> s/\s+/g;<br> push @newdata, $_;<br>}<br><br>I haven'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 <<a href="mailto:faber@linuxnj.com">faber@linuxnj.com</a>> 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'm reading in a CSV file line by line. I need to trim leading and<br>
trailing whitespace out of each comma-delimited field. So I figured I'd<br>
use map an enclosure like so:<br>
<br>
my @data = split(/,/, $_);<br>
<br>
map { $_ => s/^\s+//;<br>
$_ => s/\s+$//;<br>
} @data;<br>
<br>
($sku,$warehouse,$quantity,$row,$product_type,$stack_location,$price)<br>
= @data ;<br>
<br>
<br>
Two things I don't understand:<br>
<br>
1) why is map editing my array in place? It's supposed to return an<br>
array. The array it does return has extra empty data elements in<br>
between each original element.<br>
<br>
2. Why do I get a "Useless use of a variable in void context at<br>
at_test.pl line 19." (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