I recently read this post by Elian and two of things hit me like a ton of bricks:
I have to work with really nasty data. A typical record looks like the following:
key : /C=US/A=BOGUS/P=ABC+DEF/O=CONN/OU=VALUE1/S=Region/G= +Limbi c/I=_/ type : UR flags : DIRM ADMINM ADIC ADIM Alias-2 : wL_Region Alias-3 : Limbic Region Alias-4 : Limbic._.Region@nowhere.com Alias-5 : Limbic._.Region Alias-6 : Limbic.Region@nowhere.com Alias-7 : ORG Alias-8 : CMP Alias-10 : O=ORG/OU=Some Big Division/CN=Limbic _. Region Alias-11 : Region Alias-12 : Region, Limbic _ Alias-14 : Limbic _. Region at WT-CONN Alias-15 : ex:/o=BLANK/ou=ORG/cn=Recipients/cn=Mailboxes/cn=LRe +gion Alias-16 : WT:Limbic_Region Alias-17 : SMTP:Limbic._.Region@nowhere.com Alias-18 : /o=A.B.C.D./ou=Vermont Ave/cn=Recipients/cn=wt/cn=Li +mbic_Regi on Full Name : Region, Limbic _. Post Office : WT-CONN Description : 999-555-1212 Some Big Company Tel : 999-555-1212 Dept : Some Big Division Location : EMWS Address : 123 nowhere street City : everywhere State : MD Zip Code : 20874 Building : BLAH Building-Code : MD-ABC owner : CONN
I am typically batch processing records, and not obtaining a single record. The problem is, that the only tools we currently have for this is shell scripts with a lot of VERY ugly sed. Even then, there are a great deal of limitations. I have written a few custom scripts in Perl, but they really aren't re-useable as each task is different.
This seems like a perfect place to use a module.
Here are some issues I can see up front:
These are the main things I will need to do:
Here is what I envision:
#!/usr/bin/perl -w use strict; use DBParser; # My new module I haven't built yet open (OUTPUT,"> /tmp/somefile") or die $!; select OUTPUT; $|++; $/=""; while (<>) { my $key = DBParser::KeyGrab($_); my %record = DBParser::DBParse($_); next unless ($record{$key}->{Key}->{Surname} eq "Region"); $record{key}->{Tel} = "(123) 456-7890"; print DBParser::PrintRecord; }
I certainly don't want anyone to write this module for me - the whole point in the project is to learn. I do however want pointers, advice, snippets of code, etc. Feel free to reply as though this was a meditation, if all you have to offer is methodologies and not actual technical solutions.
Thanks in advance - L~R
In reply to My first package - need help getting started by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |