Thank you for your time and your valuable help is much appreciated.
        I made the changes to the program like you suggested, however I get
this error, when I run the program!

        ##############################
         A3 GD > perl CSV.PL;
        Global symbol "$line" requires explicit package name at csv.pl; line
6.
        Execution of csv.pl; aborted due to compilation errors.
        %SYSTEM-F-ABORT, abort
        ##############################

        The modified program:
        #######################################################
        #!/path/to/perl -w
        use strict;

        open CSV,"<vt04-07-01.csv" or die "Cannot open vt04-07-01.csv",$!;
        open NEW,">vt04-07-01.csv-changed";
        while($line=<CSV>){
                chomp;

                my @fields = split ',';

                splice @fields, 2, 1;

                for (@fields) { print NEW "blah $_\n" }
        }
        close CSV;
        close NEW;
        exit;

        [End of file] 
        ########################################################

        ##########
        <snip>
> ### 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
        ############

> Thanks,
        Kind Regards,
>  GD

Reply via email to