about special chars when split() 
Author Message
 about special chars when split()

Hi,all
I am doing a log analyzer on Winroute log. But I donot know how to
process special characters when split().Such as the following line:
"192.168.1.25 - muwei [03/Sep/2001:14:23:45 +0800] "GET
http://www.*-*-*.com/
=b1 HTTP/1.0" 302 296"

Many chars need to be escaped. Is there any method to substitute?



Tue, 30 Mar 2004 08:00:48 GMT  
 about special chars when split()
[Posted and mailed]



Quote:
> I am doing a log analyzer on Winroute log. But I donot know how to
> process special characters when split().Such as the following line:
> "192.168.1.25 - muwei [03/Sep/2001:14:23:45 +0800] "GET
> http://www.microsoft.com/isapi/redir.dll?Prd=ie&Pver=5.0&Ar=ie5update&O1
> =b1 HTTP/1.0" 302 296"



This takes a line and splits it into fields, if they're separated
by whitespace.  Looks good to me.

Quote:
> Many chars need to be escaped. Is there any method to substitute?

"escaped"?  What do you mean?  Splitting the line and "escaping"
characters are two different operations.  What kind of "escaping" are
you talking about?  For the shell?  For the web?  HTML?  URL?

I think you're mixing up to completely different operations.

--
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*

"If you rush a Miracle Man,     for details, see http://geeksalad.org    
        you get rotten Miracles." --Miracle Max, The Princess Bride



Sat, 03 Apr 2004 02:53:35 GMT  
 about special chars when split()


Quote:
> I am doing a log analyzer on Winroute log. But I donot know how to
> process special characters when split().Such as the following line:
> "192.168.1.25 - muwei [03/Sep/2001:14:23:45 +0800] "GET
> http://www.microsoft.com/isapi/redir.dll?Prd=ie&Pver=5.0&Ar=ie5update&O1
> =b1 HTTP/1.0" 302 296"



This is a task for matching delimiters, not split()ing.

# Typical input lines:
# uu.net /jms - [12/Apr/1995:06:36:33 -0700] "GET / HTTP/1.0" 200 2512
# uu.net /jms - [23/Dec/1996:06:36:33 -0700] "GET / HTTP/1.0" 200 2512 "R" "U"
  ($host,$user,$auth,$timestamp,$command,$status,$size) =
   /(\S+) (\S+) (\S+) \[(.*)\] "([^"]*)" (\d+) (.*)/;
# Logs created on my ISP after 1-Apr-96 have HTTP_REFERER and HTTP_USER_AGENT
  if ($size =~ /(\d+) "([^"]*)" "(.*)"/) {
     ($size,$referer,$useragent) = ($1,$2,$3);
  } else {
     $referer = $useragent = "";
  }
  ($verb,$file,$vers) = split(' ',$command,3);      # GET, POST or HEAD
  ($verb,$file,$vers) = ($command,"-","-") unless $file;    # For "-"

        -Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.



Sat, 03 Apr 2004 11:02:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Replacing special chars with special chars

2. split on special chars (++)

3. Shell special chars in file names?

4. pattern matching with special char

5. escape special chars before loading into MySQL

6. Special chars

7. special chars

8. Text::CSV with Special Chars?

9. perl/sendmail: encoding special chars

10. is there a way to escape special chars

11. Newbie - Escaping special chars in forms

12. Dealing with the special chars in the file name

 

 
Powered by phpBB® Forum Software