in reply to CGI script to read CSV file and modify for web output

You probably want to look into the DBI and DBD::CSV modules, which provide an interface. translation of pseudocode:
use Fcntl qw(LOCK_EX LOCK_UN); my $header = 'foo'; my $footer = 'bar'; my $prefix = 'baz'; open CSV,$csvfile; open OUTPUT,">$header"; flock OUTPUT,LOCK_EX; $, = ","; # output field seperator, joins lists passed to print while (<CSV>){ print OUTPUT $prefix,$_; # no need to split; # just so you know : @list = split(/,/,$_); # will do the trick better than $var1,$var2... # but you want to chomp($_) first, and set $\ to "\n" perh +aps # then you print OUTPUT $prefix,@list # and CSV is done for you. } print OUTPUT $footer; flock OUPTUT,LOCK_UN; # not really needed, i think close OUTPUT; close CSV;


-nuffin
zz zZ Z Z #!perl

Replies are listed 'Best First'.
Re: Re: Urgent help required
by ronan76 (Initiate) on Oct 18, 2002 at 11:19 UTC
    Thanks, i appreciate your help and time ronan