Dietmar Thal wrote:
hi there,I think this is what you are wanting:
this is not really a particular perl/win-question, but i am
confident, that someone could give me a helping hand.
i try to parse my apache <error.log> for the last error
encountered.
i managed reading the whole file in $inStr and regexp all
the stuff away except the last lines, which contain the
recent error description. (see code below)
my problem is now, that i want to cut away all the '[.*]'
stuff, e.g.
[timestamp1] [remote user1] description line 1
[timestamp2] [remote user2] description line 2
[timestamp3] [remote user3] description line 3
gets
description line 1
description line 2
description line 3
but if i use
$lastErrStr =~ s/\[.*\]//g;
it cuts all from the first '[' to the last ']'
which results in
[timestamp1] description line 3
^
(that bracket isn't there at this point, just for demonstration puposes)
so how can i cut parts of a string, which occurs
several times?
my $abc = q([timestamp1] [remote user1] description line 1);
$abc =~ s/\[.*?\]//g;
print $abc;
The ? tells perl regexpr to not be greedy, and only match the FIRST instance, and to NOT continue trying to expand the match to find all expanded possibilities. And because you have used the /g it will repeat this until no further NON-greedy matches are found.
--thanks for any advice. (and please explain what you are doing, because i am willing to get used to regexp's :))my code: while ($inStr =~ /\[(.*)\] \[/g) { $cLine = $1; } $lastErrStr = substr($inStr,index($inStr,$cLine)); $lastErrStr =~ s/\n/<br>/g; ########## what to do here? ### #$lastErrStr =~ s/\[.*\]//m; print $lastErrStr; Dietmar
Regards, Kul http://akakul.co.uk/
Backup Solutions: http://camelbackup.com/ FREE Scripts: http://scripts.akakul.co.uk/
Get Summarizer; the Admin tool for Webalizer
http://scripts.akakul.co.uk/summarizer/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
