Hi, i'm new here don't judge lol. Anyways im having troubles with trying to match a regex, i had it somewhat working but not now. I seem to have a problem that $info seems to go out of scope or something i put a print before and after where it seems to just loose its string.
my $column_separator = ","; my $column_number = "4"; $column_number--; my $str = "APPCRASH."; my $file_in = 'c:\perl\week3\WindowsApplicationEvent.csv'; my $file = 'c:\perl\week3\scan.'.$str.'.txt'; my @strings = ("APPCRASH.","he protected system file.","EMET_DLL Modul +e logged the following event:.","your virus/spyware.","A new process +has been created\\..","A service was installed in the system\\..","A +scheduled task was created\\..","Logon Type:[\\W]*(3|10).","\\\\Softw +are\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run.","service termi +nated unexpectedly\\..","service was successfully sent a.","service e +ntered the.","service was changed from."); my @found = (); my $count = 0; open (LOGFILE, $file_in); print "Opening Eventfile...\n"; my @lines=<LOGFILE>; open (OUT, ">>", $file) or die "$!"; foreach my $info (@lines){ ++$count; chomp($info); foreach my $string(@strings) { #print " string-->$string\n\n"; #print "BEFORE \n\n $string \n\n $info \n\n"; #if($info =~ m{^$string$}) #if ($info =~ m/$string/) #print " check --> $check"; #if (grep (m{^$string$}), $info) if ($info =~ m{^$string$}) { #print "AFTER $info \n"; push (@found, "Line # $count -> $info "); print OUT "Line # $count -> $string --> $info \n"; #print "Extractig line $count ...\n"; } } }
sorry for the long input file info, i just feel it may help, again thank you guys for looking int o this for me
FILE CONTENTS
9/9/2013,1:42:00 PM,gupdate,Information,None,0,N/A,DANIEL-3332D452,The description for Event ID ( 0 ) in Source ( gupdate ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Service stopped. 9/9/2013,1:42:00 PM,gupdate,Information,None,0,N/A,DANIEL-3332D452,The description for Event ID ( 0 ) in Source ( gupdate ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Service started. 9/9/2013,12:57:52 PM,Bonjour Service,Error,None,100,N/A,DANIEL-3332D452,CacheRecordAdd: _apple-mobdev._tcp.local. (PTR) got immediate answer burst (10); restarting exponential backoff sequence (243486) 9/9/2013,12:56:11 PM,Bonjour Service,Error,None,100,N/A,DANIEL-3332D452,CacheRecordAdd: _apple-mobdev._tcp.local. (PTR) got immediate answer burst (10); restarting exponential backoff sequence (81162) 9/9/2013,10:54:40 AM,iPod Service,Information,None,0,N/A,DANIEL-3332D452,The description for Event ID ( 0 ) in Source ( iPod Service ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Service started/resumed. 9/9/2013,10:50:50 AM,VMUpgradeHelper,Information,None,271,N/A,DANIEL-3332D452,Restored network configuration. 9/9/2013,10:50:50 AM,VMUpgradeHelper,Information,None,270,N/A,DANIEL-3332D452,Not restoring network configuration for adapter with MAC address 00:0C:29:74:43:A7. The device ID for this adapter is unchanged. 9/9/2013,10:50:49 AM,VMUpgradeHelper,Information,None,258,N/A,DANIEL-3332D452,Restoring network configuration. 9/9/2013,10:50:48 AM,TPAutoConnSvc,Information,None,0,N/A,DANIEL-3332D452,The description for Event ID ( 0 ) in Source ( TPAutoConnSvc ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: TPAutoConnect Service started.. 9/9/2013,10:50:46 AM,MySQL,Information,None,100,N/A,DANIEL-3332D452,"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: ready for connections. Version: '5.5.15' socket: '' port: 3306 MySQL Community Server (GPL)
FILE CONTENTS
In reply to Regex problem i think? by StalkinYerMa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |