rjreb has asked for the wisdom of the Perl Monks concerning the following question:

I finally upgraded a mail server from Debian Lenny to Wheezy and now a script for my mail admin broke. I believe the relevant lines are

use strict; BEGIN { my $dir; require File::Spec; if ( !($dir = $ENV{MT_HOME}) ) { $dir = ($0 =~ m!(.*[/\\])!) ? $1 : './'; $ENV{MT_HOME} = $dir; } unshift @INC, $dir; } # # Include Logger module # Calls on VMA::Logger module # use VMA::Logger qw(Logger); # # Grab arguments from command line # Split argument into array # my @argarray = split(/:/,$ARGV[0]); my $is_logging = $argarray[0]; my $logdir = $argarray[1]; my $func = $argarray[2];

Now when I try and run it I get

Use of uninitialized value in split at /var/www/vmailadmin/includes/bin/backend.pl line 42.

I'm just looking for some direction here on what changed between 5.8 and 5.14 that would cause this. Any help would be most appreciated.

Replies are listed 'Best First'.
Re: Upgrade from 5.8 to 5.14 broke me
by syphilis (Archbishop) on Aug 08, 2013 at 23:36 UTC
    Use of uninitialized value in split at /var/www/vmailadmin/includes/bin/backend.pl line 42

    Assuming that line 42 of /var/www/vmailadmin/includes/bin/backend.pl is
    my @argarray = split(/:/,$ARGV[0]);
    then it's $ARGV[0] that's uninitialized.

    Did you forget to provide a command line argument ?

    Cheers,
    Rob
      That would probably help. When I add an address I now get this.

      # /var/www/vmailadmin/includes/bin/backend.pl "test@example.com"
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 84.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 114.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 160.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 200.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 266.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 299.
      Use of uninitialized value $func in regexp compilation at /var/www/vmailadmin/includes/bin/backend.pl line 337.

      Line 84 contains

      if ( grep /^$func$/, @domain_manager ) { use VMA::DomainManager qw\createDomainHome removeDomainHome\; # # Set varibles from input # my $facility = "domainmgr"; my $cachedir = $argarray[3]; my $uid = $argarray[4]; my $gid = $argarray[5]; my $home = $argarray[6]; my $host = $argarray[7]; my $system = $argarray[8]; if ( $func eq 1001 ) { createDomainHome($home,$host,$uid,$gid,$system,$is_log +ging,$logdir,$facility); } elsif ( $func eq 1002 ) { removeDomainHome($home,$host,$cachedir,$is_logging,$lo +gdir,$facility); } }
        I found out that I needed to add a sudo rule. Not certain why it wasn't required before.

        # vMail.Admin rule for apache
        Host_Alias HOST = hostname.of.server
        www-data HOST = NOPASSWD: /var/www/vmailadmin/includes/bin/backend.pl