What I do when I want to do something to each line of a file is break it up
into an array with one line per element of the array.  That way I can put in
conditions that let me decide which lines I want to do it to.  For example:

open(INFILE,"infile.csv");
@infile = <INFILE>;
close INFILE;

foreach $line(@infile){
   $line = "insert ".$line;
}

open(OUTFILE,">infile.csv");
print OUTFILE @infile;



-----Original Message-----
From: Jon Molin
To: bc
Cc: [EMAIL PROTECTED]
Sent: 1/24/02 5:44 AM
Subject: Re: csv flat file

bc wrote:
> 
> hello
> 
> i have a flat file (csv) [it has about 114 rows]
> 
> i want to put the word "insert " in front of each row,
> 
> how it the "for each" writtin?  in other words, in perl, how do i do a
for each row insert the word "insert ", then it comes out of the "for
each" loop thingy...?

perl -pi.bak -e 's/^/insert /' filename

would do it (remove .bak if you don't want a  backup)

/jon

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to