<span style="font-family: courier new,monospace;">I haven't tried running your code, so forgive me if I'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>@<<<<<<<<<<<<<<<<@##########@##########@##########<br>$date, $col1, $col2, $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 "perl format" 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> <<a href="mailto:princeton-pm-request@pm.org">princeton-pm-request@pm.org</a>> 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> <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> <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 'help' to<br> <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> <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 "Re: Contents of Princeton-pm digest..."<br>
<br><br>Today's Topics:<br><br> 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 <<a href="mailto:gsaray101@yahoo.com">gsaray101@yahoo.com</a>><br>Subject: Re: [Princeton-pm] processing cells in a file<br>To: princeton perl group <<a href="mailto:princeton-pm@pm.org">princeton-pm@pm.org
</a>><br>Message-ID: <<a href="mailto:884427.8446.qm@web51902.mail.re2.yahoo.com">884427.8446.qm@web51902.mail.re2.yahoo.com</a>><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,"<test.csv");<br><br>$row=-1;$col=-1;<br>while (<FILE>) {<br> chomp;<br> if (/^[0-9]/) {<br> chomp;<br> $row++;<br> $col = -1;<br> foreach $char (split /,/) {
<br> $col++;<br> $cell[$row][$col]=$char;<br> }<br> }<br>}<br><br>for $i (0..$#cell) {<br> $aref = $cell[$i];<br> $n = @$aref - 1;<br> for $j (0..$n) {<br> print "$cell[$i][$j],";
<br> }<br> print "\n";<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>