in reply to Re^2: just another search program
in thread just another search program

Maybe you missed the bit where I said

but it's not clear whether there could be multiple Network Name/Interface groups per file? The following assumes not.

If there are multiple 'Network name'/'Interface name' groups in each file, then you could adapt my solution with an extra outer loop, but you would probably be better to use one of the other solutions.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: just another search program
by sunny (Initiate) on Feb 14, 2006 at 08:23 UTC
    hello
    #use strict; #use warnings; $/=undef; $d=<DATA>; print " Hello\n"; print if $d=~ /Device |interface |VRID|state|primary address/i; my (@ip)=($d=~m/number addresses(?:.*?)((?:\d{1,3}\.){3}\d{1,3})/gsi); print "The addresses are: ". join("\n",@ip)."\n"; __DATA__ logging to Device F01 is 19.9.16.11... Showing the vrrp status VRRP Interfaces Interface WEB_A Authentication: NoAuthentication VRID 39 State: Master Time since transition: 582693 hfghfghfghghghfghfhhfgh Primary address: 195.51.205.220 Number addresses: 1 195.51.205.222 Monitored circuits: Afgh_A (priority 1fgh50) SRghf1 (priority 1fgh50) Interface DATA_DL Nufghfghmber of vhfghl roufgh Fgfhfghs: AuthefghfgntichoAhfhication VRID 2556 State: Master Time since transition: 13405375 Bahfgh Flafghfghgs: Advertfghdl: 1 Rfghfghfgval: 3fghfghfgh fghfsgh VfghfghVRghfg Vh Primary address: 19.18.27.65 Next advertisement: 0 Number addresses: 1 15.12.57.234 I logging to Device L2 is 14.359.1.2... Showing the vrrp status VRRP Interfaces Interface SDC_A Nughujgj AuthentijghjghjNoAuthentication VRID 9 State: Backup Time since transition: 582695 Mghjghjer: hgjghjghj0 BahhjFlags: Adverghjad Interval: 3 VMAChj VMAhj1:ef Primary address: 195.51.205.221 Masghjghjg Number addresses: 1 195.51.205.222 Interface SA Numbehgjghjr of virtualj: 1 Fghjg Authentijghjtion VRID 7 State: Backup Time since transition: 582695 Master: 62.187.224.12 Baseghjghj4 Flags: Advertisement ihjghjRouterhjghj3jghjVRRP VMAC: ghj:01jghj Primary address: 62.187.224.13 Mastghjghj Number addresses: 1 6.17.26.14
    this code just prints only the IP Address below the "number address". it doesnt't print the Device name,interface name,VRID,State,Primary address.

    whats wrong in it ?
Re^4: just another search program
by sunny (Initiate) on Feb 15, 2006 at 08:09 UTC
    hi

    can you just add up a loop ? its not working for me ?

      I've posted an extended example that processes multiple Networks per file below, but you may not understand how it works, and may therefore hove problems adapting it for your real program.

      Given your current level of Perl skill, I think that you are more likely to understand one of the other solutions presented in this thread, particularly grandfather's with which you have already had extensive help. I think that you should probably get yourself a good Perl book and take the time to play with a few small programs of your own before attempting more complicated tasks.

      produces

      C:\test>junk1 A, WEB_A, 145, Master, 194.551.205.250, 1, 135.51.045.242 A, WEB_B, 145, backup, 19.51.205.20, 2, 135.51.05.22, 321.654.987.111 A, WEB_C, 145, backup, 19.51.205.20, 3, 135.51.05.22, 123.456.789.001, + 321.654.987.111 B, WEB_A, 145, Master, 194.551.205.250, 1, 135.51.045.242 B, WEB_B, 145, backup, 19.51.205.20, 2, 135.51.05.22, 321.654.987.111 B, WEB_C, 145, backup, 19.51.205.20, 3, 135.51.05.22, 123.456.789.001, + 321.654.987.111

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.