in reply to Re: module return
in thread module return

ya, very good notes for creating new module.
"We need the 1; at the end because when a module loads Perl checks to +see that the module returns a true value to ensure it loaded OK. You +could put any true value at the end (see Code::Police) but 1 is the c +onvention."
The above lines have bean given for that cause. according to my understanding. "if you give 1 at end of the module, perl loads the module, otherwise not loaded". is it correct????

Replies are listed 'Best First'.
Re^3: module return
by Anonymous Monk on Aug 17, 2009 at 11:18 UTC
    No. 1 indicates it loaded successfully, otherwise it failed to load successfully. use/require die when it fails to load successfully, but its still loaded.
    D:\>echo package asdf; $VERSION = 5; 1; >asdf.pm D:\>perl -Masdf -e 1 D:\>echo package asdf; $VERSION = 5; 0; >asdf.pm D:\>perl -Masdf -e 1 asdf.pm did not return a true value. BEGIN failed--compilation aborted. D:\>perl -e " eval { require asdf; 1 } or warn $@; die $asdf::VERSION +" asdf.pm did not return a true value at -e line 1. 5 at -e line 1.