Perl Code

Jerry Benton jerry.benton at mailborder.com
Thu Jan 28 21:40:21 UTC 2016


Yeah, that is what I figured. I moved the package away from compiling and installing custom Perl modules last year in favor of distro provided modules. I have been testing without that block and it seems ok. Seems …


-
Jerry Benton
www.mailborder.com



> On Jan 28, 2016, at 4:38 PM, Danny <danny at tweegy.nl> wrote:
> 
> 
> 
> Op 28-1-2016 om 21:29 schreef Jerry Benton:
>> Can someone better than me at Perl, which isn’t really hard to do, try to make some sense of this? I am thinking this isn’t really applicable since Perl has pretty much been standardized. This is at the beginning of /usr/sbin/MailScanner.
>> 
>> I am think I can cut this down to:
>> 
>>   require MIME::Base64;
>>   require MIME::QuotedPrint;
>> 
>> 
>> ---
>> 
>> 
>> # Awkard BEGIN block so that we pick up MIME::Base64 from the right place!
>> BEGIN {
>>   my(@oldinc, at safecopy,$path, at corepaths, at notcorepaths);
>> 
>>   my $seensv = 0;
>>   foreach $path (@INC) {
>>     if ($path =~ /site|vendor/i) {
>>       $seensv = 1;
>>     }
>>     if ($seensv) {
>>       push @notcorepaths, $path unless $path eq '.';
>>       next;
>>     }
>>     # If it's a simple path before site or vendor, save it for the end
>>     if ($path =~ m#/usr/(local/)?lib\d*/perl\d*/\d\.\d#) {
>>       push @corepaths, $path;
>>     } else {
>>       push @notcorepaths, $path;
>>     }
>>   }
>> 
>>   # Now we have all the site and vendor paths in @notcorepaths, and the
>>   # perl5 paths in @corepaths. We want notcore + core, so the notcore ones
>>   # take priority.
>>   #print STDERR '@INC = ' . "\n" . join("\n", @INC) . "\n";
>>   @INC = (@notcorepaths, @corepaths);
>>   #print STDERR '@INC = ' . "\n" . join("\n", @INC) . "\n";
>> 
>>   # Look in /usr/local/mailscanner/utils for the modules
>>   @oldinc = @INC;
>>   @safecopy = @INC;
>> 
>>   # Duplicate path with /usr/local/mailscanner/utils stuck on the front
>>   # of each element
>>   foreach $path (reverse @oldinc) {
>>     next unless $path =~ /\//;
>>     $path =~ s/^\/usr/\/share\/mailscanner\/perl/;
>>     unshift @INC, $path;
>>   }
>> 
>>   require MIME::Base64;
>>   require MIME::QuotedPrint;
>> 
>>   @INC = @safecopy;
>> }
>> 
> I thinks the code wants to make sure a customized version of those MIME modules located at /usr/share/mailscanner/perl are used if they exist and the path already exists within @INC.
> 
> Regards,
> Danny
> 
> 
> -- 
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/listinfo/mailscanner



More information about the MailScanner mailing list