in reply to Re: Perl Regex
in thread Perl Regex
#!/usr/bin/perl chdir("/tmp") or die "$!"; opendir (DIR, ".") or die "$!"; my @files = grep {/2010*/} readdir DIR; close DIR; { local @ARGV = @files; foreach my $file (@files) { open(FILE,"/tmp/$file") or die "No file!"; ############################### while ($fields = <FILE>) { @logs = split (/ /,$fields); # split log fields by space. foreach $msg (@logs) { #if ( $msg=~(/^msg="(.*?)"/)) #if ( $msg=~(/msg=/)) if ( $msg=~/\bmsg="[^"]*"/) #if ($message =~ /msg=\"+((?:([^:,]+):\s|)([^,]+?)\s*(?:\s +*,.*?|))\"+/) { print "$msg\n"; } } } close(FILE); } } close FILE; exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl Regex
by afoken (Chancellor) on Nov 23, 2010 at 11:03 UTC | |
by cipher (Acolyte) on Nov 23, 2010 at 11:12 UTC | |
by cipher (Acolyte) on Nov 23, 2010 at 11:53 UTC | |
by CountZero (Bishop) on Nov 23, 2010 at 16:31 UTC |