Activate ik/fk match via enum attribute


hi guys,
i am trying to automate ik/fk match via attribute. My idea is to launch the script
when I change an enum attribute. Reading around I understood that the only way is through the scriptJob command. I searched around, but found nothing
that could help me.
I will preface this by saying that I am really unfamiliar with mel,
I tried to write something like this, but of course it doesn’t work,

global proc l_leg_ikfk(){
int $y = getAttr l_leg_global_ctrl.switch;
if( $y = 0 )
$l_upLeg_ik = xform -query -worldSpace -rotation l_upLeg_ik;
xform -worldSpace -rotation $l_upLeg_ik[0] $l_upLeg_ik[1] $l_upLeg_ik[2] l_upLeg_fk;
$l_lowLeg_ik = xform -query -worldSpace -rotation l_lowLeg_ik;
xform -worldSpace -rotation $l_lowLeg_ik[0] $l_lowLeg_ik[1] $l_lowLeg_ik[2] l_lowLeg_fk;
$l_foot_ik = xform -query -worldSpace -rotation l_foot_ik;
xform -worldSpace -rotation $l_foot_ik[0] $l_foot_ik[1] $l_foot_ik[2] l_foot_fk;
$l_toeRoll_CTRL = xform -query -worldSpace -rotation l_toeRoll_CTRL;
xform -worldSpace -rotation $l_toeRoll_CTRL[0] $l_toeRoll_CTRL[1] $l_toeRoll_CTRL[2] l_toe_fk;
setAttr “l_leg_global_ctrl.fk_ik” 0;
else if ( $y = 1 )
setAttr “l_toeRoll_CTRL.rotateZ” 0;
setAttr “l_foot_CTRL.foot_roll” 0;
setAttr “l_foot_CTRL.in_out” 0;
setAttr “l_foot_CTRL.foot_lift” 0;
setAttr “l_foot_CTRL.toe_shift” 0;
setAttr “l_foot_CTRL.heel_shift” 0;

$l_foot_fk = xform -query -worldSpace -translation l_foot_fk;
xform -worldSpace -translation $l_foot_fk[0] $l_foot_fk[1] $l_foot_fk[2] l_foot_CTRL;
$l_foot_fk = xform -query -worldSpace -rotation l_foot_fk;
xform -worldSpace -rotation $l_foot_fk[0] $l_foot_fk[1] $l_foot_fk[2] l_foot_CTRL;
$l_toe_fk = xform -query -worldSpace -rotation l_toe_fk;
xform -worldSpace -rotation $l_toe_fk[0] $l_toe_fk[1] $l_toe_fk[2] l_toeRoll_CTRL;
$l_lowLeg_PV = xform -query -worldSpace -translation l_leg_fk_poleVector;
xform -worldSpace -translation $l_lowLeg_PV[0] $l_lowLeg_PV[1] $l_lowLeg_PV[2] l_leg_poleVector;
setAttr “l_leg_global_ctrl.fk_ik” 1;
scriptJob -attributeChange “l_leg_global_ctrl.switch” “l_leg_ikfk” ;

can someone give me a hand? thanks in advance