<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>Hi folks,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I've got a clumsy way to do regexes, and I'm looking for a better way.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I need to read the data from a file (called $name), which has the following format...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" face="Courier New">   Date   Rainfall mm</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">01/01/2000 00:00:00          27.333</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">01/01/2000 00:05:00         0.0</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">01/01/2000 02:00:00        29.15</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">01/01/2000 02:05:30        0.0</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The way I've been doing it to date is </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">open (RF, "&lt;", "$name") or die "PERRMOSS could not open file: $name!";</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">my @file     = &lt;RF&gt;;</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">chomp @file;</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Which cuts of whatever newline character there is on each line, followed by</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">for $i (1..$#file){</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">$file[$i] =~ m|(\d+)\/(\d+)\/(\d{4})\s+(\d+):(\d+):(\d+)\s*(\d.\d*)|) {</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($day,$month,$year,$hour,$minute,$second,$rain) = ($1,$2,$3,$4,$5,$6,$7);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">}</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">}</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>To accommodate some variations in the input record, I have expanded this to </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">for $i (1..$#file){</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">if ($file[$i] =~ m|(\d+)\/(\d+)\/(\d{4})\s+(\d+):(\d+):(\d+)\s*(\d.\d*)|) {</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($day,$month,$year,$hour,$minute,$second,$rain) = ($1,$2,$3,$4,$5,$6,$7);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">}</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">elsif ($file[$i] =~ m|(\d+)\/(\d+)\/(\d{4})\s+(\d+):(\d+)\s*(\d.\d*)|) {</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($day,$month,$year,$hour,$minute,$rain) = ($1,$2,$3,$4,$5,$6);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">$second = 0;}</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">elsif ($file[$i] =~ m|(\d+)\/(\d+)\/(\d{4})\s+(\d+)\s*(\d.\d*)|) {</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($day,$month,$year,$hour,$rain) = ($1,$2,$3,$4,$5);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($second,$minute) = (0,0);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">}</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">elsif ($file[$i] =~ m|(\d+)\/(\d+)\/(\d{4})\s*(\d.\d*)|) {</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($day,$month,$year,$rain) = ($1,$2,$3,$4);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">($second,$minute,$hour) = (0,0,0);</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">}</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" face="Courier New">else {print_to [$Screen,$summary], "</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">PERRMOSS cannot read rainfall data file $name near line $i</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New">PERRMOSS aborted at: \t\t$fulltime\n\n";</FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Courier New">exit;}</FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New"><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>}</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The problem is that the first value of <FONT class="Apple-style-span" face="Courier New">$rain </FONT>should equal 27.333, but it equals 27. So, there's a syntax issue, and i would be grateful for any hints.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>In terms of the bigger picture, is using <FONT class="Apple-style-span" face="Courier New">$1,$2 </FONT>etc the best way to do it?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Regards,</DIV><DIV>Martin</DIV><DIV>Visit my website...</DIV><DIV><A href="http://web.mac.com/martin_jacobs1"><SPAN class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; ">http://web.mac.com/martin_jacobs1 </SPAN></A></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN></SPAN> </DIV><BR></BODY></HTML>