Disruptive
Programmer
Hi
I am having trouble trying to read in name, value pair data from a text file. I want each name and value on each line and be able to check the value of each name or value indepently (stored in sep varables). I seem to have tied myself in knots trying to get this working.
#!/usr/bin/perl
$LOGFILE = "myfile.txt";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
chomp($line); # remove the newline from $line.
# do line-by-line processing.
# print $line;
($name, $value) = split(' ', $line);
print $name $value;
}
I am having trouble trying to read in name, value pair data from a text file. I want each name and value on each line and be able to check the value of each name or value indepently (stored in sep varables). I seem to have tied myself in knots trying to get this working.
#!/usr/bin/perl
$LOGFILE = "myfile.txt";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
chomp($line); # remove the newline from $line.
# do line-by-line processing.
# print $line;
($name, $value) = split(' ', $line);
print $name $value;
}