Cannot get the Dialstatus

Hi Everyone!

I have perl AGI, and trying to get the dialstatus after the dial command but unable to get the status in any form.

my $dialstatus = $AGI->get_variable(“DIALSTATUS”);
$AGI->verbose(“DIALSTATUS IS : $dialstatus”);

But SOMETIMES when I place multiple commands of $dialstatus = $AGI->get_variable(“DIALSTATUS”);
it gives the actul value. Also tried putting WAIT() before getting dialstatus but it dint helped.