salmjuh
asked on
Manipulating an array
Hello gurus
I have same information many times in an array which I would like to use only once before printing to a file. My array looks like this:
-------------------BEGIN-- ---------- ---------- ----
for (@sorted1[0..199]) {
@parts = split /\s*;\s*/;
print FILEOUT "$parts[5], $parts[12], $parts[10]\n";
------------------END----- ---------- ---------- ----
This gives me next result:
KAR, Tree White, TR
KAR, Stone Nice , YY
ETC, Karr Happo, YY
ETC, Renne Artma, EKD
ETC, Malk Johns, RTT
122, Veikk Jann, RTT
WSR, Mikka Routul, TRR
WSR, Wss Easy, EKD
KKK, Ar Parkk, KDE
334, Wer Moert, GH
334, Tim Paav, DFF
Etc.
Now the tricky part. I need to change this so that it gives me next result:
KAR
Tree White, TR
Stone Nice , YY
ETC
Karr Happo, YY
Renne Artma, EKD
Malk Johns, RTT
122
Veikk Jann, RTT
WSR
Mikka Routul, TRR
Wss Easy, EKD
KKK
Ar PArkk, KDE
334
Wer Moert, GH
Tim Paav, DFF
Etc.
So I like to have first column to one own line when this character string appear first time and after this all the names which belong to this same string.
How I can make it ??
Thanks advance
-JS
I have same information many times in an array which I would like to use only once before printing to a file. My array looks like this:
-------------------BEGIN--
for (@sorted1[0..199]) {
@parts = split /\s*;\s*/;
print FILEOUT "$parts[5], $parts[12], $parts[10]\n";
------------------END-----
This gives me next result:
KAR, Tree White, TR
KAR, Stone Nice , YY
ETC, Karr Happo, YY
ETC, Renne Artma, EKD
ETC, Malk Johns, RTT
122, Veikk Jann, RTT
WSR, Mikka Routul, TRR
WSR, Wss Easy, EKD
KKK, Ar Parkk, KDE
334, Wer Moert, GH
334, Tim Paav, DFF
Etc.
Now the tricky part. I need to change this so that it gives me next result:
KAR
Tree White, TR
Stone Nice , YY
ETC
Karr Happo, YY
Renne Artma, EKD
Malk Johns, RTT
122
Veikk Jann, RTT
WSR
Mikka Routul, TRR
Wss Easy, EKD
KKK
Ar PArkk, KDE
334
Wer Moert, GH
Tim Paav, DFF
Etc.
So I like to have first column to one own line when this character string appear first time and after this all the names which belong to this same string.
How I can make it ??
Thanks advance
-JS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
-js