Murphy, Ged (Bolton) wrote:
> Hi all.
Hello,
> I have a log containing strings as follows :
>
> 21259 audit O 72398 Mar 09 00:18 dll/ldr/elf.c
>
> The format is the same throughout with the exception of the 'O', as it
> doesn't always appear.
> I need to match when the 'O' appears and when it does, I need to save
> the file path, i.e. 'dll/ldr/elf.c'
>
> Here is a snippet from my code containing my regex
>
> if (/\sO\s.+([\w\/]+)$/) {
> print "found $1\n";
> ...
>
> However it's not working as expected, I assume due to the '.+' matching
> too much.
> Can someone help with the best method to do this?
I would probably do it like this:
my @fields = split ' ', $_, 8;
if ( $fields[ 2 ] eq '0' ) {
print "found $fields[7]\n";
...
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>