cnycsjohn
IS-IT--Management
- Sep 21, 2010
- 17
Hello
I'm looking to generate a document based on a csv file.
I suck at perl, and am learning as I go.
Here's what I have thus far....
It doesn't work... I think the code explains what I'm going for
Any pointers would be awesome! thank you
I'm looking to generate a document based on a csv file.
I suck at perl, and am learning as I go.
Here's what I have thus far....
Code:
#!perl -w
# open the csv for reading.
open(IPF,"csvinput.txt") or die "Failed to open csv file, $!\n";
# while info come from the IPF handle...
while ($line = <IPF>)
{
$name = '';
$description = '';
$size = '';
}
# split the parts of the line into an array.
@parts = split(/","/,$line);
$name = $parts[0]; # dereference array element
$description = $parts[1]; # dereference array element
$size = $parts[2]; # dereference array element
foreach my $name {
print "Processing $line\n";
my $new_file = "output/$name.html";
# print "new_file variable is : $new_file\n";
print "\n";
open TO_NEW_FILE, "> $new_file" or die "Cannot open $new_file for writing: $!";
print TO_NEW_FILE "$name \n"
print TO_NEW_FILE "$description \n"
print TO_NEW_FILE "$size \n"
}
It doesn't work... I think the code explains what I'm going for
Any pointers would be awesome! thank you