in reply to Using Sendmail.pm problem

$home = $ENV{"HOME"};
BEGIN { push @INC, "$home/scripts/Mail" };
use Mail::Sendmail;

This all looks rather dodgy. The variable $home doesn't get given a value until runtime, but you try to access it in a BEGIN block which is executed at compile time (i.e. before $home has a value). I think you'd be better off using:

use lib "$ENV{HOME}/scripts/";

I've left off the "Mail" from that path as because it's part of the module name, you don't need it in the library path.

I'm also a bit dubious about how you installed the module. Creating directories and copying files around is prone to failure. I'd really recommend that you did it again using the standard "perl Makefile.PL / make / make test / make install" commands. I realise that you don't have permission to install modules into the central library, but you can pass arguments to "perl Makefile.PL" to get round that.

Having said all that, I'm surprised by the error message you get. I would expect you to see an error saying that the module couldn't be loaded successfully.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: Using Sendmail.pm problem
by tariqahsan (Beadle) on Sep 22, 2006 at 14:43 UTC
    Surprisingly as I mentioned it works fine in a different server.
    I know I should try to get this perl module installed
    in the right way. I'll try to see if I can tweak something in the perl module itself to make it work for now.

    Any suggestions in this regard would be much appreciated.

    Thanks

      There's no point in trying to "tweak something in the perl module" as the Perl module is almost certainly not being loaded successfully. The problem is not with the module, it is with how you installed the module and how your are subsequently trying to load it.

      If it works on another server then perhaps the sysadmin on that other server has already installed it, so your broken attempt to change @INC is having no effect.

      Try running this from the command line of the server where it works. This will tell you where the file is being loaded from:

      perl -MMail::Sendmail -le 'print $INC{"Mail/Sendmail.pm"}'
      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        Aha! This is what I am getting running -

        perl -MMail::Sendmail -le 'print $INC{"Mail/Sendmail.pm"}'
        gmitest1@mckinley..gmdwit: /home/gmitest1/juice/scripts => Mail/Sendma +il.pm Mail/Sendmail.pm: package: not found Mail/Sendmail.pm[6]: =head1: not found Mail/Sendmail.pm[8]: Mail::Sendmail: not found Mail/Sendmail.pm[10]: =cut: not found Mail/Sendmail.pm[12]: =: not found Mail/Sendmail.pm[18]: syntax error at line 19 : `(' unexpected
        Any more suggestions?

        Thanks!