Thanks for all the help now it works

use strict; use warnings; my $returncode; $returncode = 0; open (my $IN,"<E:/scripts/eva/allupdates.log") || die "can not open da +tei: $!"; #regex für Datumsanalyse matcht auf Datum z.B. 30.11.2010 my $redate='((?:(?:[0-2]?\\d{1})|(?:[3][0,1]{1}))[-:\\/.](?:[0]?[1-9]| +[1][012])[-:\\/.](?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3})))(? +![\\d])'; # DDMMYYYY 1 #Datumsbestimmung tatsächliches Datum: (my $sec, my $min, my $hour, my $mday,my $mon, my $year, my $wday, my +$ydat, my $isdst)=localtime(); my $jahr=$year; my $monat=$mon+1; my $tag=$mday; $jahr=$year; $jahr=$year +1900; if (length($monat) == 1) { $monat="0$monat"; } if(length($tag) == 1) { $tag="0$tag"; } if(length($hour) == 1) { $hour="0$hour"; } if(length($min) == 1) { $min="0$min"; } if(length($sec) == 1) { $sec="0$sec"; } my $Xdatum=$tag.".".$monat.".".$jahr; my $Xzeit=$hour.":".$min.":".$sec; #$Xdatum="$jahr$monat$tag"; #$Xzeit="$hour$min$sec"; #print $Xdatum." ".$Xzeit; #Datum im Logfile evawp.log my $datelogfile; #Vergleich Datum in Logdatei mit Systemdatum, wenn dies gleich ist, ok +, $redate matcht auf Datumsstring, der 1. String ist das Datum ... while(<$IN>){ if( /($redate)(\s+).*?(Ende)/i){ print " ,1. Variable $1\n"; $datelogfile = $1; print " Datelogfile $datelogfile\n"; print " Var Xdatum $Xdatum\n"; if ( $datelogfile eq $Xdatum) { print " Variable datelogfile $datelogfile\n"; $returncode++; } print; print "$returncode\n"; } } #wenn error nicht gefunden wurde dann auch die Datei nicht öffnen zum +schreiben ... #für jeden Fund wird returncode um 1 erhöht ... if ( $returncode == 1 ){ print "Update TS ok!\n"; } #Wenn Returncode 0 ist der String nicht gefunden, dann Fehler ... if ( $returncode <= 0 ){ print "Update TS FEHLER!\n"; } #print "$returncode\n"; close $IN; #print "$datelogfile \n"; system("pause");

Thanks
MH

In reply to Re^2: Parse Log File for Date and string? by matze77
in thread Parse Log File for Date and string? by matze77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.