How to do it?
With this small example you can see how a simple perl program to edit a TAP3 looks like.
Decode
 |
|
 |
|
1 #!/usr/bin/perl
2 use TAP3::Tap3edit;
3 $tap3 = TAP3::Tap3edit->new;
4 $tap3->decode("CDOPER1OPER200001") or die $tap3->error;
5 $struct=$tap3->structure; |
|
 |
|
 |
This is the first step to work with TAP3::Tap3edit. With these five lines we just decode the TAP file "CDOPER1OPER200001". Let's go line by line.
1. Tells the shell which kind of script this is and which program it should run. Please make sure that your perl is located under this directory. In some Unix versions is under /usr/local/bin/perl. For windows you may write the location on windows e.g. c:/perl/bin/perl.exe (please note it is /, and not \).
2. In this line we tell perl that we are going to use the module TAP3::Tap3edit. Perl may here complain if the package is not installed.
3. We create a new instance of the object TAP3::Tap3edit. Its name is $tap3.
4. Here the package method "decode" is used to decode the file CDOPER1OPER200001.
5. The complete structure of the file is stored in the variable $struct. Here is important to notice that the file has been already decoded and its complete information (tree) is stored in this variable.
Structure change
After decoding we want to change something from the file. Let's change for example the UTC Offset.
Well if you are acquainted with the structure of a TAP file you'll see that in the line 6 we just change the "UTC Offset" of the "Earliest Call" inside the "Audit Control Information"
Note: Please note that in this case we changed an ASCII field. If you need to change a hexadecimal field like for example the IMSI, you need to convert the value first to hexadecimal.
Encode
Ok. Until now it doesn't look that complicated. So now that we changed our structure, we need to encode it.
 |
|
 |
|
1 #!/usr/bin/perl
2 use TAP3::Tap3edit;
3 $tap3 = TAP3::Tap3edit->new;
4 $tap3->decode("CDOPER1OPER200001") or die $tap3->error;
5 $struct=$tap3->structure;
6 $struct->{transferBatch}{auditControlInfo} {earliestCallTimeStamp}{utcTimeOffset} = "+0300";
7 $tap3->encode("CDOPER1OPER200001.new") or die $tap3->error; |
|
 |
|
 |
In that 7th line we see how we encode the changed structure into a new file. So after running the script we will have the original file and a file ".new" with the changes.
Well, you've just seen how this tool works to change something in a file. I think now you got the feeling what this is about and you may want to try it by yourself. I recommend taking look to the requirements of the installation.
|