Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create page from csv

Status
Not open for further replies.

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....

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 :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top