Take some hints from the followingexample:
use Modern::Perl; use Text::CSV; my $csv = Text::CSV->new() or die "Cannot use CSV: " . Text::CSV->erro +r_diag(); open my $fh_in, '<', "test.csv" or die "test.csv: $!"; open my $fh_out, '>', "test_new.csv" or die "test_new.csv: $!"; while ( my $line = <$fh_in> ) { my $status = $csv->parse($line); my ( $field1, $field2, $field3, $field4 ) = $csv->fields(); $status = $csv->combine( $field3, $field2, $field1, $field4 ); my $output_string = $csv->string(); print $fh_out $output_string; }
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial DeltronicsIn reply to Re: i need to join two fields in .csv file??
by CountZero
in thread i need to join two fields in .csv file??
by mano2991
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |