Hello everyone,
I have a string from an apache log file:
192.168.1.1 - - [05/Jul/2001:22:48:51 -0500] "GET /test.php HTTP/1.1"
200 995
How could I get the IP (192.168.1.1) out of that? I've been playing
with regexps like this:
if/(.*)\s-\s-\s/;
but I have no idea if that's correct or not. Can
On Thu, Aug 09, 2001 at 08:35:42PM -0500, Tyler Longren wrote:
: Hello everyone,
:
: I have a string from an apache log file:
: 192.168.1.1 - - [05/Jul/2001:22:48:51 -0500] "GET /test.php HTTP/1.1"
: 200 995
: How could I get the IP (192.168.1.1) out of that? I've been playing
: with regexps l
since you know that the first thing on the log file is the IP number you
only need to get the beginning of the line
IP numbers have the format ddd.ddd.ddd.ddd ranging from 1 to 3 digits,
so
if(/$(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) would grab the IP and put it
in $1
the above will match IP numb
- Original Message -
From: "Akshay Arora" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>
Cc: "perl-beginners" <[EMAIL PROTECTED]>
Sent: Thursday, August 09, 2001 7:24 PM
Subject: Re: result of regexps into a string
> sin
Hello Chasey and Akshay!
> You could use a regex:
>
> $log_line =~ /([\d.]+)\s/;
> my $ip_addr = $1;
> IP numbers have the format ddd.ddd.ddd.ddd ranging from 1 to 3 digits,
> so
> if(/$(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) would grab the IP and put it
> in $1
> the above will match IP numb