[OpenSIPS-Users] Indexing AVPs with other AVPs... set from perl
Jock McKechnie
jock.mckechnie at gmail.com
Tue Jan 25 22:41:52 CET 2011
Greetings all;
I have a feeling I'm "almost there, but not quite" with this one, I was
wondering if someone can point out the missing piece of my puzzle here.
I'm attempting to index an AVP with another AVP, which works just fine in
OpenSIPS, but I'm attempting to seed the initial AVP array from an exec'd
perl routine. Problem is, I'm not sure if the perl AVP routines can actually
address indexed AVPs...
My perl looks (vaguely) like this:
my $idx = 0;
while(my $Data = &Get_Data) {
OpenSIPS::AVP::add("MAGIC[$idx]", "$Data");
$idx++;
}
Which I discovered I can access like this:
xlog("L_INFO", "Displaying index 0: $avp(s:MAGIC[0])\n");
Note the position the [0] index - according to all the documentation it
_should_ look like this: $(avp(s:MAGIC)[0]). This leads me to believe that
the AVP name is being set, literally, to "MAGIC[0]" rather than a "MAGIC"
array, per se.
I'm then trying to access the AVP later with an index inside another AVP,
like so:
$avp(s:IDX) = 0;
xlog("L_INFO", "A index 0: $avp(s:MAGIC[$avp(s:IDX)])\n");
xlog("L_INFO", "B index 0: $(avp(s:MAGIC)[$avp(s:IDX)])\n");
Both of which return a <null>. The former because I don't think you can
insert a string into an AVP name in the manner I'm (accidentally) doing, and
the latter because MAGIC it isn't an array like it should be.
What's the appropriate way of doing this? Can I mangle the AVP name and
simply have a list of several named AVPs rather than using the array feature
- or is there a way of access the indices from the OpenSIPS::AVP::add()?
Thanks!
- Jock
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20110125/24a8d569/attachment.htm>
More information about the Users
mailing list