#!c:/perl/bin/perl
use strict;
use warnings;
#opening the csv file
my $caption=pop(@ARGV);
open(FH,$caption) || die("Cannot open $caption file");
my($line,$id,$name,$age,@records,@out);
@out="
CSV Output| ID | NAME | AGE | ";
#creating a new file for the html output and writing the header content
open(FH1,">output.html");
print FH1 @out;
#splitting the comma separated values and writing it to the html file
while($line=){
next if($line=~/^ID/);
chomp($line);
($id,$name,$age)=split(/,/,$line);
print FH1 "| $id | $name | $age |
";
}
print FH1 "
";
close FH1;
close FH;
####
ID,NAME,AGE
1,JOHN,21
2,MARK,32
3,CATHY,21
####
CSV Output| ID | NAME | AGE |
| 1 | Alex | 24 |
| 2 | Bret | 21 |
| 3 | Cathy | 24 |
####
#!c:/perl/bin/perl
use strict;
use warnings;
$\="\n";
my($caption,$line,@out,@rec,$x,@output);
#opening the csv file
$caption=pop(@ARGV);
open(FH,$caption) || die("Cannot open $caption file");
#print '';
#print '' . $caption . '';
@out="CSV Output$caption";
open(FH1,">gen_try.html");
print FH1 @out;
while($line=){
chomp($line) ;
@rec = split(/,/, $line);
$x=0;
print '';
while($x <= $#rec){
print FH1 "\t | ". $rec[$x] . ' | ';
++$x;
}
print '
';
}
print '
';