<span style="font-family: courier new,monospace;">I haven&#39;t tried running your code, so forgive me if I&#39;m way off here...<br><br>It sounds like you might want to try writing to a format. Something like:<br>=========================================
<br>my ($date, $col1, $col2, $col3);<br>format STDOUT =<br>@&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;@##########@##########@##########<br>$date, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $col1,&nbsp;&nbsp;&nbsp;&nbsp; $col2,&nbsp;&nbsp;&nbsp;&nbsp; $col3<br>.<br><br>in your loop you would set the above variables to the correct values and then:
<br><br>write STDOUT;<br></span><span style="font-family: courier new,monospace;">=========================================</span><br><span style="font-family: courier new,monospace;">google &quot;perl format&quot; if this sounds like what you want.
<br><br>Hope it helps.<br><br>Regards,<br><br>Tim<br></span><br><br><br><br><br><div><span class="gmail_quote">On 8/22/07, <b class="gmail_sendername"><a href="mailto:princeton-pm-request@pm.org">princeton-pm-request@pm.org
</a></b> &lt;<a href="mailto:princeton-pm-request@pm.org">princeton-pm-request@pm.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send Princeton-pm mailing list submissions to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:princeton-pm@pm.org">princeton-pm@pm.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://mail.pm.org/mailman/listinfo/princeton-pm">
http://mail.pm.org/mailman/listinfo/princeton-pm</a><br>or, via email, send a message with subject or body &#39;help&#39; to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:princeton-pm-request@pm.org">princeton-pm-request@pm.org</a><br><br>You can reach the person managing the list at
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:princeton-pm-owner@pm.org">princeton-pm-owner@pm.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than &quot;Re: Contents of Princeton-pm digest...&quot;<br>
<br><br>Today&#39;s Topics:<br><br>&nbsp;&nbsp; 1. Re: processing cells in a file (mike smith)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Wed, 22 Aug 2007 10:56:37 -0700 (PDT)
<br>From: mike smith &lt;<a href="mailto:gsaray101@yahoo.com">gsaray101@yahoo.com</a>&gt;<br>Subject: Re: [Princeton-pm] processing cells in a file<br>To: princeton perl group &lt;<a href="mailto:princeton-pm@pm.org">princeton-pm@pm.org
</a>&gt;<br>Message-ID: &lt;<a href="mailto:884427.8446.qm@web51902.mail.re2.yahoo.com">884427.8446.qm@web51902.mail.re2.yahoo.com</a>&gt;<br>Content-Type: text/plain; charset=iso-8859-1<br><br>there is a csv file like this:
<br>date, val1, val2, val3, val4 etc<br>1/2/2007, 1, 4, 5, 6<br>1/3/2007, 2, 5, 7, 10<br>1/5/2007, 5, 6, 8, 11<br><br>what I need to do is, calculate the differnce between<br>cells for each column and write it to a file. for
<br>example, since there is no previous value to row one,<br>write first row to a file. then subtrack second raw<br>values from the first row values and write the output<br>to the second line in ouptput file - (2-1, 5-4, 7-5,
<br>10, 6). Third raw in the output file should be, 5-2,<br>6-5, 8-7, 11-10 and so on. I have the code below but<br>having trouble formatting the output file. The ouput<br>file should be like the first raw of the input file,
<br>the other lines should start with time stamp in the<br>first column of input file and symetric cell<br>subtration. Can anybody look at this and provide<br>insight?<br><br><br>Code: ( perl )<br>#!/usr/local/bin/perl<br>
use Data::Dumper;<br>open(FILE,&quot;&lt;test.csv&quot;);<br><br>$row=-1;$col=-1;<br>while (&lt;FILE&gt;) {<br>&nbsp;&nbsp;&nbsp;&nbsp;chomp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if (/^[0-9]/) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chomp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$col = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach $char (split /,/) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$col++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cell[$row][$col]=$char;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>for $i (0..$#cell) {<br>&nbsp;&nbsp;&nbsp;&nbsp;$aref = $cell[$i];<br>&nbsp;&nbsp;&nbsp;&nbsp;$n = @$aref - 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;for $j (0..$n) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;$cell[$i][$j],&quot;;
<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;print &quot;\n&quot;;<br>}<br><br><br><br><br>____________________________________________________________________________________<br>Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
<br><a href="http://smallbusiness.yahoo.com/webhosting">http://smallbusiness.yahoo.com/webhosting</a><br><br><br>------------------------------<br><br>_______________________________________________<br>Princeton-pm mailing list
<br><a href="mailto:Princeton-pm@pm.org">Princeton-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/princeton-pm">http://mail.pm.org/mailman/listinfo/princeton-pm</a><br><br>End of Princeton-pm Digest, Vol 13, Issue 1
<br>*******************************************<br></blockquote></div><br>