in reply to need to remove the extra line in regular expression

Now, it would also be good to have your "config.txt" file, but I'm going to try to answer your question anyway.

You have two print statements in your code, the second is conditional, if it contains an IP address you parse it and print it, but the first print is not conditional, you print $arr[0] on every iteration of the loop. If you want to print it only when you find an IP address, put this in the if statement too.

Take my advice. I don't use it anyway.
  • Comment on Re: need to remove the extra line in regular expression

Replies are listed 'Best First'.
Re^2: need to remove the extra line in regular expression
by ulaksh (Acolyte) on Aug 22, 2012 at 13:32 UTC
    I have added the config file please refer that
      You forgot the code tags again
        I have update the code , please refer that
      I have added the code, please refer that

        Look at line 8 of your code, this print should be inside the if statement to achieve the result you expect.

        Simply replace line 13 with print "$arr[0] => $ipaddr\n";

        Take my advice. I don't use it anyway.