A co-worker supports a POS system. At month end, system A creates some new XML, and sends them to System B that processes them into a billing system.
Problem is that System B only handles a 10 character OPERATORID value, and System A will create 12 character OPERATORID's. So hundred's of these are rejected. cute, eh?
So we get System A to only send 10 chars, right? wrong.
For whatever reason, this co-worker decided to HAND MASSAGE the files and using notepad to truncate all the rogue >10 chars strings.
Last month the system spit out over 400 of these rejections (business is picking up!).
while watching this co-worker hand-massage these files, I decided to write up a quick script to do it for him.
It's not going to win any prizes in a perl contest, but it sure solved a huge problem for my co-worker.
The file works against one file at a time (it started as an attempt at a one-liner, but time was of the essence and I was not clever enough to do it that way). I wrote a second perl script to build a big .BAT file from the directory listing the files resided in. The batch file executes this script against each file.
I thought I would just share the story, but I will be brave and include the code, such as it is.
#!perl.exe # invoke as follows: # perl -p -i.BAK posfix.pl FILENAMETOPROCESS # if ( /OPERATORID/ ) { $_ =~ s/<OPERATORID>//; $_=~ s/<\/OPERATORID>//; $_=substr($_,0,10); $_ = "<OPERATORID>". $_ . "</OPERATORID>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Quick solutions to easy problems
by tilly (Archbishop) on Aug 18, 2000 at 00:28 UTC | |
by Mushy (Scribe) on Aug 18, 2000 at 01:15 UTC | |
by wardk (Deacon) on Aug 18, 2000 at 20:09 UTC | |
|
RE: Quick solutions to easy problems
by merlyn (Sage) on Aug 18, 2000 at 06:30 UTC | |
|
RE: Quick solutions to easy problems
by tenatious (Beadle) on Aug 21, 2000 at 05:44 UTC | |
|
RE: Quick solutions to easy problems
by Anonymous Monk on Oct 08, 2000 at 07:38 UTC |