Hi,

the problem you have is not a bit one, so the solution is fairly simple..
however, there are some issues you need to concider in your script, so let
me show you a few pointers:

### USE STRICT AND -w I can not stress that enough!!! ###

#!/path/to/perl -w
use strict;

### use CAPS for filehandles to avoid conflicts with reserved words... use
$ARGV in both places, or neither.... ###
open CSV, "$ARGV[0] or die "Cannot open $ARGV[0]",$!;
open NEW,">vt04-07-01.csv-changed";

### we'll put all the input into $_ it makes things easier i think... ###
while (<CSV>) {

    ### kill trailing \n ###
    chomp;

    ### split the fields on comma's from $_ and put them in @fields ###
    my @fields = split ',';

    ### 3rd element of @fields holds unwanted info, we'll splice it out...
perldoc -f splice for more details ###
    splice @fields, 2, 1;

    ### an arbitrary print statement to show you all went well
    for (@fields) { print NEW "blah $_\n" }

    ### feel free to add more code in... ###
}

hope this helps,

Jos Boumans


<snip>

> What I need to delete from the file is: Field [3]
> Can any body please suggest what else needs to be added to the
> script that I wrote below to do this task please.
> THE PROGRAM so far:

> open csv,"<vt04-07-01.csv" or die "Cannot open $ARGV[0]",$!;
> open new,">vt04-07-01.csv-changed";
> while($line=<csv>){
>         chomp $line;
>
>         $fields[3] =~
>
> }
> close csv;
> close new;
> exit;
>
> [End of file]
>
>
> Any help would be much appreciated as I only have two days to this
> in!!!
> Thanks,
> GD
>

Reply via email to