What u are asking for is to have a configuration file.  You can easily create
one and then have a subrotuine to parse your configuration file ... ie read
the conf file and determine which is the starting position for the field.

for example read the conf file and have an array that stores the starting
position .. so following your code frag. the starting position array would
look like
@start_pos = (9,15,40,15);
then you need to break up your format string into a loop or it will be hard to
maintain.

On Fri, Aug 24, 2001 at 12:57:38PM +0100, Govinderjit Dhinsa shaped the electrons to 
read:
>       UPDATED QUESTION 
>       ~~~~~~~~~~~~~~~~
>       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]
>       
> ############################################################################
> ###########
> 
>       How do I get this bit......
>       ################################
>       printf
> ORG"%-9s%-15s%-40s%-15s\n",$fields[0],$fields[1],$fields[2],$fields[3];
>       
> ############################################################################
> ############
>       ......of the program to be in a separate file (which will then be
> called from the program), so that the parameters (would be in a file by them
> self with nothing else but them), can be changed whenever necessary!
> 
>       <So the parameter file would look something like this>
>       
> ############################################################################
> ##########
>       $fields[0]  start at position 9
>       $fields[1]  start at position 15
>       $fields[2]  start at position 40
>       $fields[3]  start at position 15
>       
> ############################################################################
> ##########
> 
>       NOTE;
>       * The start positions will always be changed.
> 
>       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