use threads; #added use threads::shared; my $var : shared; if (threads::shared::_id($var)) {#pass the var not the ref print("'\$var' is shared\n"); }