Maybe you can consider something like this ... after reading in from the ORG
file and splitting the elements into @fields ... you can so something along
these lines

        for my $field (@fields) {
                my $field_length = length($field);
                my $format = "%-".$field_length."s";
                printf NEW $format , $field;
        }
        close .. exit ...

sorry about having to put the format into a different variable but i could not
properly escape the format string properly ..

On Fri, Aug 24, 2001 at 11:13:10AM +0100, Govinderjit Dhinsa shaped the electrons to 
read:
>       I have a program that reads an input file and outputs the file, with
> where I want each field to start from!
>       <PROG>
>       
> ############################################################################
> ##########
>       open ORG,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!;
>       open NEW,">$ARGV[1]";
>       while($line=<ORG>){
>               chomp $line;
>               @fields = split ',',$line;
> 
>       printf
> ORG"%-9s%-15s%-40s%-15s\n",$fields[0],$fields[1],$fields[2],$fields[3];
> 
>       }
>       close ORG;
>       close NEW;
>       exit;
>       [End of file]
>       
> ############################################################################
> ###########
> 
>       What I need help on please is 'How to specify at the COMMAND LINE
> where I want each field to start from',
>       INSTEAD of specifying it from the in the programme!
> 
>       At the moment I specify the positions in the programme by;
>       ################################
>       printf
> ORG"%-9s%-15s%-40s%-15s\n",$fields[0],$fields[1],$fields[2],$fields[3];
>       
> ############################################################################
> ############
>       NOTE;
>       * The number of fields very all the time, as different input files
> will have different amounts of fields.
>       * The start positions will always be different.
> 
>       PS. Any help and advice would be very much appreciated.
> 
>       Regards,
>       Govin.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to