Chinaunix

标题: 求助,文本中取特定行。 [打印本页]

作者: dgww    时间: 2011-08-11 16:35
标题: 求助,文本中取特定行。
本帖最后由 dgww 于 2011-08-11 16:36 编辑

==== Group 001====
  Title:    Haproxy - testadmin
  Username: admin
  Url:      http://1.1.1.1:10243/test-haproxy
  Password: 122233
  Comment:  test-web1

  Title:    mysql - testbackup
  Username: testbackup
  Url:      
  Password: 123444
  Comment:  

  Title:    mysql - root
  Username: root
  Url:      
  Password: 122223
  Comment:  

  Title:    server01
  Username: admin
  Url:      1.1.1.1
  Password: 99999
  Comment:  test-web1
==== Group 002====
  Title:    mysql - testbackup
  Username: testbackup
  Url:      
  Password: 123444
  Comment:  

   Title:    another-server02
  Username: admin
  Url:      
  Password: 88888
  Comment:  test-web2
  
  Title:    mysql - root
  Username: root
  Url:      
  Password: 122223
  Comment:  

  Title:    Haproxy - testadmin
  Username: admin
  Url:      http://1.1.1.2:10243/test-haproxy
  Password: 122233
  Comment:  test-web2

.......
.......
.......
.......

文本如上,我需要取出server01的admin密码999999;another-server02的admin密码:88888
作者: x9x9    时间: 2011-08-11 16:49
创建个hash of hashs:

%hash= (title的值=>{Username=>'',Url=>‘’, ... }, ....)




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2