Hello,
I am new to perl and I would like to parse a csv file in perl. The current code I have opens a file and prints new output to the terminal. I'm wondering how to write to print this information into the file instead of to the terminal. I tried to use
open (FILE, ">>gps_sample.txt") but it wouldn't print to the file. Below is my current code.
#!/usr/bin/perl
#use warnings;
#use strict;
my $string_type;
my $timestamp;
my $validity;
my $lat;
my $ns;
my $lon;
my $ew;
my $speed;
my $true;
my $date;
my $variation;
my $ew2;
my $check;
open (FILE, 'gps_sample.txt');
while (<FILE>) {
chomp;
($string_type, $timestamp, $validity, $lat, $ns, $lon, $ew, $speed, $true, $date, $variation, $ew2, $check) = split(",");
print "String Type: $string_type\n";
#print FILE "String Type: $string_type\n";
print "Time: $time\n";
print "Validity: $validity\n";
print "Latitude: $lat\n";
print "North/South: $ns\n";
print "Longitude: $lon\n";
print "East/West: $ew\n";
print "Speed: $speed\n";
print "True Course: $true\n";
print "Date: $date\n";
print "Variation: $variation\n";
print "East/West: $ew2\n";
print "Check: $check\n";
print "---------\n";
}
close (FILE);