What are valid Perl module return values? -


The common thing in Perl is that 1; End the module with so that the call can be checked for success, is there any reason why the return value can not be another real value? In my test, this does not seem to be the cause of any problem, but I would like to know if anyone has any issues (such as some other modules or prejs or some values ​​that are actually assumed on 1 And not just the truth).

EDIT: By popular opinion, and because it will work only once (good tip), the code example has gone, the consensus is that it is safe to return any true value, But never calling in that value should not believe because requirement will return 1 after first loading

I have been fooled at the end of my module for a while I keep things. There is no harm in it and it has a small easter egg "Yes, this code is a joke." There is a full crack in them.

Take this one step further, sometimes when a function is returned to true and false i true I'll return anything other than 1. This is to punish those who write if foo () == 1 , they mean if foo () it was around the same period that I was typing < Code> use constant = TRUE = & gt; 1 == 1; Continuous FALSE = & gt; ! TRUE;

I have seen the return value of the module used in the output code. I do not remember why the developer's logic was actually ... torture I believe that it was not like writing two lines instead of two. I do not remember why he did not export it only.

This was the same developer who passed the debate around % _ ( * _ symbol global in the package ) And map descriptions have written 150 line map details.

By removing the danger of using the return value, it works only once.

Foo.pm package $ Foo; The return "Basket Hoods got long ears"; $ Cat test.plx #! / Usr / bin / perl -w Print foo is required, "\ n"; Print is required, "\ n"; $ Pearl-I Test.plx evaluates Foo.pm and calculates return value for the first call

for long ears near Basset hounds . The second call already looks in % INC and just gives the truth and you can not even make sure that you are the first thing you need to code. You can meet it with the do "Foo.pm" but now each time you are reloading modules with the precautions about the redefined routine, problems for display and possibly global Resume is not worth it.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -