stevbutt has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
I am loading some log files and need to extract the username when it appears, the problem is there is some variety in the way it is reported
What I have been trying is this
my ( $user ) = $remainder =~ m/user=\s*(\S+)/;my string contained in remainder can contain the user in the following formats
.... user=jtkirk, ip=[::ffff:127.0.0.1], top=0,.... .... user=<jtkirk@enterprise.com>, ip=[::ffff:127.0.0.1], top=0,.... .... user="jtkirk@enterprise.com" passwd="XXXXXX"....
Just to be clear that when the username takes the form of an email address I do want to capture the whole address but dont want the quotes or > < signs
Do I need to capture the whole thing then strip the quotes etc with tr ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting my username from log
by kcott (Archbishop) on Aug 15, 2012 at 18:51 UTC | |
|
Re: Getting my username from log
by NetWallah (Canon) on Aug 15, 2012 at 16:17 UTC | |
by stevbutt (Novice) on Aug 15, 2012 at 16:33 UTC | |
by stevbutt (Novice) on Aug 15, 2012 at 16:42 UTC | |
|
Re: Getting my username from log
by aitap (Curate) on Aug 15, 2012 at 17:00 UTC |