in reply to splitting csv file and saving data
You'll get lots of "Use XYZ::CSV module" replies despite that they don't help with your main problems, and add unnecessary complexity.
This is how I would tackle the problem described:
#! perl -sl use strict; while( <DATA> ) { my( $name, $number, $type, $text ) = m[^([^,]+),(\d+),(\d+|"[^"]+" +),(\d+)?$]; #" $type =~ s["([^"]+)"][$1]; #" printf "%s layernumber %d datatype %s%s%s\n", $name, $number, ( $type =~ m[,] ? join( ' datatype ', split ',', $type ) : $ty +pe ), ( defined( $text ) ? ' text ' . $text : '' ), ( $name eq 'NWER' ? ';' : ',' ) ; } __DATA__ NPLUS,32,0, NW,41,0,1 NWER,51,"0,1,2",12
Produces:
C:\test>junk44 NPLUS layernumber 32 datatype 0, NW layernumber 41 datatype 0 text 1, NWER layernumber 51 datatype 0 datatype 1 datatype 2 text 12;
|
|---|