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

Hi,

I have written a perl program to send emails automatically using Email::Send::Gmail module under cygwin environment.

#!/bin/perl use strict; use warnings; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my $from = undef; my $to = undef; my $subject = undef; my $body = undef; my $username = undef; my $password = undef; my $numArgs = $#ARGV + 1; if($numArgs < 6) { print "Less number of arguments than expected...\n"; print "Execute as - EmailSend.exe from to subject body_file userna +me password\n"; print "Eg: EmailSend.exe venkatesan.gangadharan@gmail.com g.venkat +esan@level3.com Test body.txt venkatesan.gangadharan@gmail.com xxxx"; exit(0); } elsif($numArgs > 6) { print "More number of arguments than expected...\n"; print "Execute as - EmailSend.exe from to subject body_file userna +me password\n"; print "Eg: EmailSend.exe venkatesan.gangadharan@gmail.com g.venkat +esan@level3.com Test body.txt venkatesan.gangadharan@gmail.com xxxx"; exit(0); } $from = $ARGV[0]; $to = $ARGV[1]; $subject = $ARGV[2]; $body = $ARGV[3]; $username = $ARGV[4]; $password = $ARGV[5]; my $email = Email::Simple->create( header => [ From => $from, To => $to, Subject => $subject, ], body => $body, ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => $username, password => $password, ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@;

The above program worked fine until recently. I made some modifications in the program and tested it previously. The program throwed some errors testing, so i reverted back to my previous working code. The problem now is eventhough i reverted my code to the previous working code, when i run the program (as ./EmailSend.pl), cygwin still throws the same old errors.

My Results:
$ ./Emailtest_backup_2.pl
Possible unintended interpolation of @gmail in string at ./Emailtest_backup_2.pl line 24.
Possible unintended interpolation of @level3 in string at ./Emailtest_backup_2.pl line 24.
Possible unintended interpolation of @gmail in string at ./Emailtest_backup_2.pl line 24.
Possible unintended interpolation of @gmail in string at ./Emailtest_backup_2.pl line 31.
Possible unintended interpolation of @level3 in string at ./Emailtest_backup_2.pl line 31.
Possible unintended interpolation of @gmail in string at ./Emailtest_backup_2.pl line 31.
Global symbol "@gmail" requires explicit package name at ./Emailtest_backup_2.pl line 24.
Global symbol "@level3" requires explicit package name at ./Emailtest_backup_2.pl line 24.
Global symbol "@gmail" requires explicit package name at ./Emailtest_backup_2.pl line 24.
Global symbol "@gmail" requires explicit package name at ./Emailtest_backup_2.pl line 31.
Global symbol "@level3" requires explicit package name at ./Emailtest_backup_2.pl line 31.
Global symbol "@gmail" requires explicit package name at ./Emailtest_backup_2.pl line 31.
Execution of ./Emailtest_backup_2.pl aborted due to compilation errors.

If you could see the code, the program should produce the following output:

Less number of arguments than expected... Execute as - EmailSend.exe from to subject body_file username password Eg: EmailSend.exe venkatesan.gangadharan@gmail.com g.venkatesan@level3 +.com Test body.txt venkatesan.gangadharan@gmail.com xxxx

But it is giving the output of my previous tests.

Could anyone help me to sort out this problem?

Thanks in advance!!!
  • Comment on (solved - Thanks to corion) HELP: Perl Program working unexpectedly under cygwin environment
  • Select or Download Code

Replies are listed 'Best First'.
Re: HELP: Perl Program working unexpectedly under cygwin environment
by Corion (Patriarch) on Oct 14, 2009 at 12:53 UTC

    I'm sure you've already read perldiag, so I'm at a loss what part of that documentation is unclear to you. Maybe you can help us improve the text to make it clearer:

    > splain Possible unintended interpolation of @gmail in string at ./Emailtest_b +ackup_2.pl line 24. Possible unintended interpolation of @gmail in string at ./Emailtest_backup_2.pl line 24 (#1) (W ambiguous) You said something like `@foo' in a double-quoted st +ring but there was no array @foo in scope at the time. If you wanted a literal @foo, then write it as \@foo; otherwise find out what happ +ened to the array you apparently lost track of.
Re: (solved - Thanks to corion) HELP: Perl Program working unexpectedly under cygwin environment
by Anonymous Monk on Apr 28, 2016 at 14:26 UTC
    Hi Corion, I am also facing the same issue. Can you please help me Regards, Prabhu R

      Have you read this thread? It has the solution.

      Also, look at line 24. This was where the problem was last time.

Re: HELP: Perl Program working unexpectedly under cygwin environment
by venkatesan_G02 (Sexton) on Oct 14, 2009 at 13:16 UTC
    Hi,

    I understand that when Perl sees something like "leon@gmail.com", it attempts to interpolate an array @gmail, and if there is no such array in the program, Perl warns that this interpolation might be unintended...

    And i also learnt (from perlmonks :)) that it should be used as leon\@gmail.com or engulf it within single quotes

    But the issue i have is, though i am not specifying any arguments with the program, the code somehow checks for "@gmail" "@level3" and i don't understand how the program assumes these arrays (though i am not providing any command-line input.

    As per program,
    ./EmailSend.pl should display error message that ther is "less number of inputs available." but the code checks for @gmail, @level3 (which is not even coded in the program).

    Any insight into this problem, please?

      Have you looked at line 24?

        Hi Corion,
        I understood the problem. I apologize for posting this silly question here, which i should have solved by myself. But i dunno how i missed it.
        Thanks for pointing it out to me