Hey Perl Guru's:)
I'm hoping that someone can help me out... I have a regular'ol ASCII
file which I'll need to read only the first line, and parse the three
numbers that are seperated by commas and print the results.

This file will always consist of the same lines, but the numbers will
be different. For example, here is a paste from the ASCII file:
62.7, 28.8, 5.6
 <body> ,N701455F:sL065 WaterSensor Dry. </body></html>

 <body> eN701462F:hL066 WaterSensor Dry. </body></html>

All I care about is the numbers listed in the first line.
First Number = Temperature
Second Number = Humidity
Third Number = Illumination

I want to parse each of these into a format such as this:
Current Temperature:  $temp
Current Humidity: $humidity
Current Illumination: $lumes

How do I go about opening this file, reading the first line, parsing
the three numbers into variables, then printing the results?

So far, this is what I have but look at the results printed below:
#!/usr/bin/perl
#
# Set Vars
my $date=`date`;

#
# Run Program
#
print "content-type: text/html \n\n";
print "<HTML><BODY><P>";
print "<HEAD><title> Data Center Temperature</title></HEAD>";
print "<H2> Data Center</H2> ";
print "Date: $date  ";
print '<form action="dctemp.pl" method=post> <P> <P>';
print "<BR>";
open(DCTEMP,"/tmp/current_dctemp");
while (<DCTEMP>){
chomp;
($temp, $humidity, $lumes) = split(",");
print "<BR>";
print "Temperature: $temp\n";
print "Humidity: $humidity\n";
print "Illumination: $lumes\n";
        print "$_ \n";
}
close (DCTEMP);
#

RESULTS:
Temperature: 62.4 Humidity: 29.0 Illumination: 5.6 62.4, 29.0, 5.6
Temperature: Humidity: N701455F:eL065 WaterSensor Dry.
Illumination: ,N701455F:eL065 WaterSensor Dry.
Temperature: Humidity: Illumination:
Temperature: eN701462F:sL066 WaterSensor Dry. Humidity: Illumination:
eN701462F:sL066 WaterSensor Dry.
Temperature: Humidity: Illumination:

Thanks for any help! :-)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to