NEVERSLEEP
Programmer
hi just a question regarding home made modules :
lets my module is :
so the script :
will print hello
ok how can i make my module abort compilation if
in somesub $_[0] is not defined ?
i DONT mean something like :
more like :
so in this 2nd script :
i want to get this error message :
"somemodule::somesub need a passed parameter at name.pl line 2"
instead of :
"use of unisialized value at somemodule.pm line 2"
i hope im clear enough if not TELL me !
ANY help/tips/sugjestion will be VERY apreciated
thanks alot
![[atom] [atom] [atom]](/data/assets/smilies/atom.gif)
---------------------------------------
someone knowledge ends where
someone else knowledge starts
lets my module is :
Code:
package somemodule;
sub somesub { print $_[0]; }
1;
so the script :
Code:
#!perl -W
use somemodule;
somemodule::somesub('hello');
will print hello
ok how can i make my module abort compilation if
in somesub $_[0] is not defined ?
i DONT mean something like :
Code:
sub somesub {
print "ERROR" unless ($_[0]);
print $_[0];
}
more like :
Code:
sub somesub {
# check if something was passed to 'somesub'
# if not abort compilation of script !
# printing some custom message like
# somemodule::somesub need a passed parameter
print $_[0];
}
so in this 2nd script :
Code:
#!perl
use somemodule;
somemodule::somesub; # on no i made a error !
i want to get this error message :
"somemodule::somesub need a passed parameter at name.pl line 2"
instead of :
"use of unisialized value at somemodule.pm line 2"
i hope im clear enough if not TELL me !
ANY help/tips/sugjestion will be VERY apreciated
thanks alot
![[atom] [atom] [atom]](/data/assets/smilies/atom.gif)
---------------------------------------

someone knowledge ends where
someone else knowledge starts