Krister Sandberg wrote:
> 
> Hi,
> 
> I would like to replace a column in a file with a prespecified constant
> say, 31.
> 
> How should I do this?
> 
> /Krister

How is your file structured ?
What have you already tried ?

I assume that between two columns is a tab.
I assume also that your file comes as <> in your perl script
and the replaced file can be written to standard output
Then the following should do what you want:

my $COLUMN_TO_CHANGE => 3; # or what you need
my $NEW_VALUE = 31;

while (<>) {
        chomp;
        my @cols = split /\t/;
        $cols[$COLUMN_TO_CHANGE] = $NEW_VALUE;
        print join "\t", @cols, "\n";
}


Greetings,
Andrea

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

Reply via email to