Can anyone help me with a quick PERL question?

James Marcinek jmarc1 at jemconsult.biz
Sat Oct 9 00:36:18 UTC 2004


Dave,

Like I said before this is the first question I had related to perl in years so
I didn't have a list to quickly post to. On the other hand there's a range of
technology related to various subject (eg Samba, LDAP, SENDMAIL, etc) that are
commonly asked here.

I had tried several variations including the \d+ but could not understand why it
wasn't matching. Once I took the $ out I started getting hits. I also had
changed the \w* to .*.

The one problem I still had was a hidden character ^M but I ended up getting it
to work with the following (could still probably clean it up):

if ($raw =~
/(^<\d\d\d>)(\w\w\w)\s+(\d\d)\s+(\d\d\d\d)\s*(\d\d:\d\d:\d\d):\s+(%\w\w\w-\d+-\d+):\s+(\w.*)\s/s
)

This took care of the ^M which now brings me to my next problem. I reformatted
the file to import into a MySQL database that I'm going to create. Does anyone
know if there will be a problem with the last field because there are several
single (') in the field?

('<165>', '2004-10-01', '19:57:52', '%PIX-5-111008', 'User 'enable_15' executed
the 'logging trap 5' command.' ),

The last field: 'User 'enable_15' executed the 'logging trap 5' command.'

I'm hoping that it won't but if anyone can tell me I'd appreciate it.

Thanks Dave


Dave Mitchell <davem at iabyn.com> wrote: 
> On Fri, Oct 08, 2004 at 11:38:20PM -0000, James Marcinek wrote:
> > First off let me state that I don't want to have to subscribe to a list
> > for just one question and I'm assuming that someone out here in this
> > technical savy group can help me.
> 
> You should try www.perlmonks.org for perl-related questions.
> 
> > if ($raw =~
> >
/(^<\d\d\d>)(\w\w\w)\s+(\d\d)\s+(\d\d\d\d)\s*(\d\d:\d\d:\d\d):\s+(%\w\w\w-\d+-\d+):\s*(\w*$)

> 
> That last \w* should be .* instead - you want to match whitespace as well
> as alphanumerics.
> Also the <\d\d\d> proably wants to be <\d+> - its unlikely ot always be
> three digits.
> 
> -- 
> This email is confidential, and now that you have read it you are legally
> obliged to shoot yourself. Or shoot a lawyer, if you prefer. If you have
> received this email in error, place it in its original wrapping and return
> for a full refund. By opening this email, you accept that Elvis lives.
> 




More information about the fedora-list mailing list