in reply to Re^7: need to remove the extra line in regular expression
in thread need to remove the extra line in regular expression

Yes I understand the code and This is my understanding the code. while(<FILE>) { =In this I am reading the complete file with file handle. $interface = $1 if /^([\S]+)/; =this line will check the one or more non whitspace char and if ti fou +nd put the value in $1 and assign to $interface. print "$interface => $1\n" if /inet addr:([0-9.]+)/; =this line will check the address and if it found put the value in $1. But I am not able to check the condition on the first line.

Replies are listed 'Best First'.
Re^9: need to remove the extra line in regular expression
by aitap (Curate) on Aug 23, 2012 at 12:18 UTC
    In this I am reading the complete file with file handle.
    No, you read it line by line, and the code inside the while(){} loop gets run once for every line in the text you read.
    But I am not able to check the condition on the first line.
    Just don't touch the second check in any way. Modify the first check, not the whole loop.
    Sorry if my advice was wrong.