hello99hello
Programmer
Hello All,
I am currently researching the following issues, and I was wondering if anyone has an input.
Basically, I have the following records ( with four fileds each, fileds 3 and 4 have varying lenght):
Jamie,Foxx,09,765
Look,Mann,87,5987
The projected output records should be:
Jamie,Foxx,00900765
Look,Mann,08705987
In summary, I want to pad the third fields with one or more leading zeros to make a three-character field. Also, I want to pad the fourth field with one or more leading zeros to make five-character field. Lastly, I want to concatenate third and fourth fields to one.
Here is my effort, This has to be done in array format:
# put the records in array
@array_file = <INPUT> ;
foreach $array_record (@array_file){
@array = split (",", $array_record) ;
#pad third element
$array[2]= array_pad($array[2], 2, 0);
$array[3]= array_pad($array[3], 5, 0);
$array[2]= $array[2].$array[3]= ;
$new_record = join ',', @array;
print OUTPUT "$new_record\n";
This does not produce the recquired output. I was wondering if anyone has other ideas.
I am currently researching the following issues, and I was wondering if anyone has an input.
Basically, I have the following records ( with four fileds each, fileds 3 and 4 have varying lenght):
Jamie,Foxx,09,765
Look,Mann,87,5987
The projected output records should be:
Jamie,Foxx,00900765
Look,Mann,08705987
In summary, I want to pad the third fields with one or more leading zeros to make a three-character field. Also, I want to pad the fourth field with one or more leading zeros to make five-character field. Lastly, I want to concatenate third and fourth fields to one.
Here is my effort, This has to be done in array format:
# put the records in array
@array_file = <INPUT> ;
foreach $array_record (@array_file){
@array = split (",", $array_record) ;
#pad third element
$array[2]= array_pad($array[2], 2, 0);
$array[3]= array_pad($array[3], 5, 0);
$array[2]= $array[2].$array[3]= ;
$new_record = join ',', @array;
print OUTPUT "$new_record\n";
This does not produce the recquired output. I was wondering if anyone has other ideas.