BEGIN { package mod; $VERSION = 1; package main; } BEGIN { if (scalar(%mod::) && $mod::VERSION ) {eval " sub haveMod () { return 1; }" ;} else {eval "sub haveMod () { return 0; }" ;} sub checkMod () { if(haveMod) {return "goodMod";} else {return "badMod";} } } print checkMod; #### C:\Documents and Settings\Owner\Desktop>perl -MO=Deparse, consttest.pl & perl c onsttest.pl BEGIN { $^W = 1; } sub BEGIN { package mod; $VERSION = 1; } sub BEGIN { if (scalar %mod:: and $mod::VERSION) { eval ' sub haveMod () { return 1; }'; } else { eval 'sub haveMod () { return 0; }'; } } sub checkMod () { do { return 'goodMod' }; } print checkMod; consttest.pl syntax OK goodMod C:\Documents and Settings\Owner\Desktop> #### #!/usr/bin/perl -w #COMMENTED OUT #BEGIN { # package mod; # $VERSION = 1; # package main; #} BEGIN { if (scalar(%mod::) && $mod::VERSION ) { eval " sub haveMod () { return 1; }" ;} else { eval "sub haveMod () { return 0; }" ;} sub checkMod () { if(haveMod) {return "goodMod";} else {return "badMod";} } } print checkMod; #### C:\Documents and Settings\Owner\Desktop>perl -MO=Deparse, consttest.pl & perl c onsttest.pl BEGIN { $^W = 1; } sub BEGIN { if (scalar %{'mod::'} and $mod::VERSION) { eval ' sub haveMod () { return 1; }'; } else { eval 'sub haveMod () { return 0; }'; } } sub checkMod () { do { return 'goodMod' }; } print checkMod; consttest.pl syntax OK goodMod C:\Documents and Settings\Owner\Desktop> #### #!/usr/bin/perl -w BEGIN { package mod; $VERSION = 1; package main; } BEGIN { if (scalar(%mod::) && $mod::VERSION ) { eval " sub haveMod () { return 1; }" ;} else { eval "sub haveMod () { return 0; }" ;} sub checkMod () { #NOTE THE PARENTHESES if(haveMod()) {return "goodMod";} else {return "badMod";} } } print checkMod; #### C:\Documents and Settings\Owner\Desktop>perl -MO=Deparse, consttest.pl & perl c onsttest.pl BEGIN { $^W = 1; } sub BEGIN { package mod; $VERSION = 1; } sub BEGIN { if (scalar %mod:: and $mod::VERSION) { eval ' sub haveMod () { return 1; }'; } else { eval 'sub haveMod () { return 0; }'; } } sub checkMod () { if (haveMod) { return 'goodMod'; } else { return 'badMod'; } } print checkMod; consttest.pl syntax OK goodMod C:\Documents and Settings\Owner\Desktop> #### C:\Documents and Settings\Owner\Desktop>cat consttest.pl & echo: & echo: & echo: & perl -MO=Deparse, consttest.pl & perl consttest.pl #!/usr/bin/perl -w #BEGIN { # package mod; # $VERSION = 1; # package main; #} BEGIN { if (scalar(%mod::) && $mod::VERSION ) { eval " sub haveMod () { return 1; }" ;} else { eval "sub haveMod () { return 0; }" ;} sub checkMod () { if(haveMod()) {return "goodMod";} else {return "badMod";} } } print checkMod; BEGIN { $^W = 1; } sub BEGIN { if (scalar %{'mod::'} and $mod::VERSION) { eval ' sub haveMod () { return 1; }'; } else { eval 'sub haveMod () { return 0; }'; } } sub checkMod () { if (haveMod) { return 'goodMod'; } else { return 'badMod'; } } print checkMod; consttest.pl syntax OK badMod C:\Documents and Settings\Owner\Desktop> #### C:\Documents and Settings\Owner\Desktop>cat consttest.pl & echo: & echo: & echo: & perl -MO=Deparse, consttest.pl & perl consttest.pl #!/usr/bin/perl -w #BEGIN { # package mod; # $VERSION = 1; # package main; #} BEGIN { if (scalar(%mod::) && $mod::VERSION ) { eval " sub haveMod () { return 1; }" ;} else { eval "sub haveMod () { return 0; }" ;} sub checkMod () { if(! haveMod) {return "badMod";} else {return "goodMod";} } } print checkMod; BEGIN { $^W = 1; } sub BEGIN { if (scalar %{'mod::'} and $mod::VERSION) { eval ' sub haveMod () { return 1; }'; } else { eval 'sub haveMod () { return 0; }'; } } sub checkMod () { if (not 'haveMod') { return 'badMod'; } else { return 'goodMod'; } } print checkMod; consttest.pl syntax OK goodMod C:\Documents and Settings\Owner\Desktop>