Quickly finding a quarantined message - was: RE:[Mimedefang]action_discard

Jan-Pieter Cornet johnpc at xs4all.nl
Thu May 10 09:50:31 EDT 2007


On Wed, May 09, 2007 at 10:30:44PM -0400, Kevin A. McGrail wrote:
> I have personally had this bite me but perhaps it is simply because I
> always use & to indicate a function call. As you stated, dropping the
> & does change the behavior.

There's a pretty good recent book out, "Perl Best Practices", published
by O'Reilly, author is Damian Conway. It's certainly an interesting
read, although I would not recommend following every "best practice"
advertised.

However, as the introduction also says, it's worth thinking about the
issues presented and how and why you choose to do it in another way.
It made my coding slightly different. I'd recommend it. (If people
are interested I can even list the chapters of the book that I
believe are really good practices, and the ones that I believe are
to be taken with a grain of salt.)

Anyway... this book recommends "function()" for all function calls,
for various reasons, and I happen to agree with Damian here. Using
"&function()" is very perl4-ish, and results in unexpected surprises
like the one you encoutered.

> The following snippet prints just once for me when most programmers
> would expect it not to print at all.

Exactly. So to avoid it, stop using that & sign to call a function :)

> &test("testing should not print");
> 
> sub test {
>   my ($test) = @_;
> 
>   &test2;
>   &test2();
> }
> 
> sub test2 {
>   my ($test2) = @_;
> 
>   print $test2;
> }

And even if they expect that, I doubt they can predict what the bowl of
spaghetti here prints:

    test("testing should not print");
    shtest("testing should not print again");
    test3("Three strokes and you're out");

    sub test {
      my ($test) = @_;
      
      &test2;
      &test2();
    }

    sub shtest {
	my $test = shift;

	&test2;
	&test2();
    }

    sub test3 {
	# call both functions with our own argument
	&shtest;
	&test;
    }

    sub test2 {
      my ($test2) = @_;
      
      print $test2, "\n";
    }

(Cheating (like feeding the above to "perl") is of course not allowed :)

This is all getting a bit far away from mimedefang, though...

-- 
Jan-Pieter Cornet <johnpc at xs4all.nl>
!! Disclamer: The addressee of this email is not the intended recipient. !!
!! This is only a test of the echelon and data retention systems. Please !!
!! archive this message indefinitely to allow verification of the logs.  !!



More information about the MIMEDefang mailing list