The defined() function tests a variable for existance and returns a value of true or false Typical variable existance testing uses might include $myScalar++ if ( defined $myScalar ); @myList = ( 1..5 ) if ( ! defined @myList ); %myHash = () if ( defined %myHash ); For subroutine names you can do runtime existance testing if ( defined &mySub ) { &mySub( "Yippee!" ); } else { die( "Darn!" ); }
if ( defined &mySub ) { &mySub( "Yippee!" ); } else { die( "Darn!" ); }