Re: simple regexp

2001-07-06 Thread Matija Papec
Mario Todorow <[EMAIL PROTECTED]> wrote: >perl -ne ' print "$1\n" if /\s(\d+\.\d+\.\d+\.\d+)\s/ ' file > >is better. Tnx, I'm already using something similar. Now there is another catch when I have to deal with two IPs in a single line. I have to use regexp in LIST context(i.e. @myips = $line =~

Re: simple regexp

2001-07-06 Thread Matija Papec
Matija Papec <[EMAIL PROTECTED]> wrote: >Array is a text file with lines as its elements. It looks like: > >--txt file-- ># ARIN: Aworldwidemall.com, VA - US >ALL: 63.64.190.230 ># ARIN: Aworldwidemall.com, VA - US >ALL: 67.64.190.230 >. >. >. >. ># ARIN: Aworldwidemall.com, VA - US >ALL: 1

Re: simple regexp

2001-07-06 Thread Mario Todorow
perl -ne ' print "$1\n" if /\s(\d+\.\d+\.\d+\.\d+)\s/ ' file is better.

Re: simple regexp

2001-07-05 Thread Mario Todorow
Try this one line command perl -ne ' print "$1\n" if /\s(\S+\.\S+\.\S+\.\S+)\s/' file Cordially Mario

Re: simple regexp

2001-07-04 Thread Matija Papec
John Edwards <[EMAIL PROTECTED]> wrote: >Here's a solution I sent to the group earlier... tnx, but I used simpler regexp since IP numbers which I use are already verified as valid. >For the array thing, have you considered using a hash instead?? How do you >know where to insert the data in the ar

RE: simple regexp

2001-07-04 Thread John Edwards
source... John -Original Message- From: George S Pereira [mailto:[EMAIL PROTECTED]] Sent: 04 July 2001 11:46 To: John Edwards Cc: 'Matija Papec'; Perl Beginners (E-mail) Subject: Re: simple regexp A simpler solution of checking for an IP address would be : #! /opt/bin/perl -w my($str)

Re: simple regexp

2001-07-04 Thread George S Pereira
A simpler solution of checking for an IP address would be : #! /opt/bin/perl -w my($str) = 'This is a string with 192.19.2.13 in it'; while ($str =~ m/(\d+\.\d+\.\d+\.\d+)/g) { if (defined $1) { print "IP address is $1\n"; } } This just prints the IP address if there is one. Ge

Re: simple regexp

2001-07-04 Thread John Edwards
Here's a solution I sent to the group earlier... For the array thing, have you considered using a hash instead?? How do you know where to insert the data in the array? Is it needed after another value, or at a certain element?? John -Original Message- From: John Edwards Sent: 14 June 2