Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I transform a file to the folowing kind!? Problem.

Status
Not open for further replies.

AlexmMorozo

Technical User
Feb 16, 2003
10
GB
Hi,
i have a file <fileP>:
y w
y u
y t
y s
y r
x w
x u
x t
x s
x r
w v
w p
v u
v t
v s
v r
u t
u s
u r
u p
t s
t r
t p
s r
s p
r p
q p



And my Q.! How can i transform this file to <fileTrans>:

10 8
10 6
10 5
10 4
10 3
9 8
9 6
9 5
9 4
9 3
8 7
8 1
7 6
7 5
7 4
7 3
6 5
6 4
6 3
6 1
5 4
5 3
5 1
4 3
4 1
3 1
2 1


A basis hier: @ar=('p','q','r','s','t','u','v','w','x','y','z');

11 elements.


Thank so much!
AL.






 
If your text is always lower case, then you can get the ASCII value for each letter and subtract 111.
 
?
Yes,you right! But what you thing about:
?


$n = 0;
%hash = map {$_, $n++} @mass;
while (<FILE>){
s/(\w)/$hash{$1}/g;
print OTHER_FILE $_;
}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top