Get SIP_CAUSE in perl script

anyone an idea how to receive the SIP_CAUSE of a channel in a perl script?

Basically I need this in my perl script:

I tried this - not working:

Any ideas?

It is not going to work unless you invoke HASH from the AGI, but I’m not 100% familiar with how AGI handles function calls, and I am not familar with your AGI access library.

I already suspected that it is not working out of the box with perl-agi.
Thanks for your help!