> Iv been givin this program to modify, but I can not astblish what some
parts
> of the program are doing.   From
>
> printf........
> to
> }
>
> Can any body help please and run through it with me pls!!!!!
>
>
>
> open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!;
> open sortcode,">$ARGV[1]";
> while($line=<iscd>){
>         chomp $line;
>         @fields=split "\t",$line;
>         printf sortcode
>
"\n%6.6s%8.8s%3.3s%27.27s%20.20s%35.35s%35.35s%10.10s%1.1s%1.1s%2.2s%2.2
s%2.
>
2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%1.1s%1.1s%6.6s%35.35s%4.4s%4.4s%10
.10s
> %8.8s",

If you're not familiar with printf strings, well,
they're a mini-language in their own right.

Basically:

    printf "foo %s %d baz", "bar", 4;

would print:

    foo bar 4 baz

and all the extra details are to do with how
many decimal digits to display, space padding,
and so on.

I don't think I'll be able to do a better job
in detail than the real doc:

perldoc -f printf
perldoc -f sprintf
man printf
man sprintf
info printf
info sprintf

>
$fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6],$field
s[7]
> ,$fields[11],$fields[14],$fields[25],
>
>
$fields[26],$fields[27],$fields[28],$fields[29],$fields[30],$fields[31],
$fie
> lds[32],$fields[33],
>
>
$fields[34],$fields[35],$fields[58],$fields[60],$fields[61],$fields[64],
>                $fields[76],$fields[77],$fields[78],$fields[79];
> }

these are all the parameters to the printf.

They're a whole bunch of elements from the @fields array.

Which in turn is created for each line from the input
file by splitting on tabs into the various @fields elements.

hth.

Reply via email to