Uncertain what you are attempting to do, but:

#!perl -w
while ( <DATA> ) {
   chomp;
   if ( /^(\d+\.\d+.\d+\.\d+)/ ) { #Extact the IP address here and stote as $1
      print "$1\n";  
    }
 }
__DATA__
192.168.0.2
This should not print

199.88.22.111
^-------- Script ends here
Output:
192.168.0.2
199.88.22.111


Wags ;)

-----Original Message-----
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 02, 2001 16:19
To: [EMAIL PROTECTED]
Subject: Silly problem


G'day All,

I have this very very simple problem that I can't figure out.  Basically
I have a 1 line text file with an IP address in it like so...

192.168.0.2

Now all I want to do is open this file up and extract the IP address
from it.  Now the good thing is I can do this OK but whenever I extract
it it seems to be appending a new line on the end of it.  Can some one
help me and give me some ideas on what I am doing wrong?  My code so far
looks like this...

open (FH, "<$file"); #...and open the textfile for reading
@line=<FH>; #Store ppp0 as an array
$line =~ /^(\d+\.\d+.\d+\.\d+)/; #Extact the IP address here and stote
as $1
print @test;
close(FH);

printing @test works fine but it appends a new line.  The code also
won't assign $1 to the IP address?

Is it something simple I am doing wrong?

Regards,

Dan

==============================
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:    http://www.vintek.net
Tel:    (08) 8523 5035
Fax:    (08) 8523 2104
Snail:  P.O. Box 312
        Gawler   SA   5118
==============================


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to