[Sussex] Parsing a Logfile with Perl....
Richie Jarvis
richie at helkit.com
Wed Mar 12 13:48:04 UTC 2008
John Crowhurst wrote:
> On Wed, March 12, 2008 10:32, Richie Jarvis wrote:
>
>> Hi All,
>>
>> I have written a little perl script to read a logfile, and parse certain
>> values for matching lines into a csv file. It works great - until I
>> tried it on one of our systems and discovered that a colleague had put a
>> '-' character into one of the usernames I am parsing. After lots of
>> cursing, I am stuck on this one, and wonder if anyone can see how to
>> adjust my regex to span the situation where usernames with and without
>> funny characters can be encompassed?
>>
>> Here is an example line from a well-formatted line:
>>
>> 2007-05-31 15:21:13 Sent SMS [SMSC:mbloxpsmsca] [SVC:fusion] [ACT:]
>> [BINF:] [from:62569] [to:16474075000] [flags:-1:1:-1:-1:-1]
>> [msg:100:01062F1F2DB69181923945413141363634383631323734414246333536363635343442423438464444353732303745433300030B6A00C54601C60001550187360603773700018707060354454D502D7B31363437343037353030307D0001873806034375]
>> [udh:12:0B05040B8423F00003210401]
>>
>
> Would it be easier to use split to carve up the strings based on the space
> delimiter and process them individually?
>
> something like:
>
> foreach $line (@logfilearray) {
> ($1,$2,$3) = split(/ /,$line); # $1, $2 to number of fields
> # process the strings here
> }
>
>
Thanks John - I've gone with that route now...
I was so hoping to get some RegEx practice in as well :(
Cheers,
Richie
More information about the Sussex
mailing list