"" <> wrote in news:c4c50034-2f90-42ce-82ca-:
[ Replying only in clpm because I can only talk about Perl ]
> is there a simple way in perl
s/perl/Perl
> 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
> Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933
> xahlee.org
> "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
> 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
> Firefox/2.0.0.13" "-"
>
> I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:
> 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13".
Simple.
#!/usr/bin/perl
use strict;
use warnings;
my $line = <<EOL;
189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
"http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
Firefox/2.0.0.13" "-"
EOL
# deal with any extra spacing and/or
# line breaks inserted in posting
$line =~ s/^\s+//;
$line =~ s/\s+$//;
$line =~ s/\s+/ /g;
if ( $line =~ /"([^"]+)" "[^"]+"\z/ ) {
print "User agent: $1\n";
}
__END__
C:\Temp> lp
User agent: Mozilla/ 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
Sinan
--
A. Sinan Unur <>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/