Perl script issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script issue
# 1  
Old 04-25-2011
Perl script issue

Hi All,

I have a perl script which I am using in Windows environment. There is one more file called "functions.txt" which is having all the functions defined to used in my perl script. And the path for this function file is defined in my perl script. Howeever sometimes I am getting below error for "mail" method used in script,

Code:
Can't call method "mail" on an undefined value at functions.txt line 153

Below is the function present in "functions.txt" file, I have added the if loop to capture the error in file.
Code:
sub ddlMail {
open (D_ALOG,"> D:/data/debug_mssql.$$.log");
 
 @ddl::env::EMAILLISTdd = split (",",$ddl::env::ddlversionEMAILLIST);
 $ddl::env::EMAILsubject = "$ddl::env::EMAIL_PREFIX1 $ddl::env::argvalueT $ddl::env::EMAIL_PREFIX2 $ddl::env::EMAILsubject";
$smtp = Net::SMTP->new('localhost');
if ( defined $smtp )
 {
 print D_ALOG "\n ddlMail::SMTP object defined\n";
 $mailman = `$ddl::env::WIN32_PATH\\whoami`;
 @mailman1 = split(/\\/,$mailman);
 chomp ($mailman1[1]);
 $mailhost = `$ddl::env::WIN32_PATH\\hostname`;
 chomp ($mailhost);
 $gdmgEmail=$ddl::env::DEFAULT_DDLEMAIL;
 
 $smtp->mail("abc@xyz.com");
 $smtp->to($ddl::env::DDLEMAIL2,@ddl::env::EMAILLISTdd); 
 
 $smtp->data;
 $smtp->datasend("From: $mailman1[1]\@$mailhost.nam.nsroot.net");
 $smtp->datasend("\n");
 $smtp->datasend("To: $ddl::env::ddlversionEMAILLIST,$gdmgEmail");
 $smtp->datasend("\n");
 $smtp->datasend("Subject: $ddl::env::EMAILsubject");
 $smtp->datasend("\n");
 $smtp->datasend("$ddl::env::contentofmail");
 $smtp->datasend("\n");
 $ddl::env::contentofmail12 = join("\n",@ddl::env::mailBodyArray);
 $smtp->datasend("$ddl::env::contentofmail12");
 $smtp->dataend;
 $smtp->quit;
}
 else
 {
  print D_ALOG "\n ddlMail::SMTP object NOT defined on the local host\n";
 }
 close (D_ALOG);
 
 }

Please advise how to fix this issue.
# 2  
Old 04-25-2011
Have a "use Net::SMTP;" in there somewhere? Sending Mail the Net::SMTP Way
# 3  
Old 04-25-2011
Yes it is declared in the very begining og my perl script.
# 4  
Old 04-25-2011
Maybe your new connection to localhost port 25 was rejected? Which line is 153?
# 5  
Old 04-25-2011
Below is the line number 153,

$smtp->mail("abc@xyz.com");

And very few I am getting this error, rest of the time script working fine.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

3. Shell Programming and Scripting

Issue regarding dos2unix perl script

Hi All, I have pearl script which will check and convert the file: INFO("dos2unix_cmds".$#{$dos2unix_cmds}); if ( $#{$dos2unix_cmds} == 0 ) { my $convert_cmd = $$dos2unix_cmds; my $rename_cmd = $$dos2unix_cmds; --conversion going here else INFO ("No need to... (8 Replies)
Discussion started by: saps19
8 Replies

4. Web Development

Accessing a Perl CGI script, security issue

Hi Everybody, I was wondering if it was possible for someone to gain access to my Perl CGI scripts before they are interpreted by Perl (mod_perl on apache2) i.e. getting a hold of my raw scripts and not the html output? Let's say I use the DBI module where I have the hostname, user and... (2 Replies)
Discussion started by: z1dane
2 Replies

5. Shell Programming and Scripting

Perl script issue: print

Can someone tell me what I'm doing wrong with my perl script? I am new to Perl. This isn't even the final script, I'm just testing to see if it will print the directories with the files in it. For some reason my output is only printing the 1st, 6th, and last entries of the @sub_dir array. Each... (3 Replies)
Discussion started by: man
3 Replies

6. Shell Programming and Scripting

Perl issue - please help!

Hello. I've been writing some code in Perl to read in strings from html files and have been having issues. In the html file, each "paragraph" is a certain file on the website. I need to find every one of the files that is a certain type, in this case, having green color....therefore... (7 Replies)
Discussion started by: akreibich07
7 Replies

7. Shell Programming and Scripting

Perl Script issue. What am I doing wrong?

#!/usr/local/bin/perl open (MYFILE, 'logs_report'); while (<MYFILE>) { $rec=$_; chomp ($rec); @arr=split(/ /,$rec); print $rec,"\n" if ($arr!~/OK/); open (MYF, '>data.txt'); print $rec,"\n" if ($arr!~/OK/); close (MYF); (14 Replies)
Discussion started by: SkySmart
14 Replies

8. Shell Programming and Scripting

Perl Issue

Hi, I got this script from the web, this generates an LDAP report in CSV format. #!/usr/bin/perl # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar&064;zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for... (23 Replies)
Discussion started by: raj001
23 Replies

9. Shell Programming and Scripting

Perl Script Issue - Please Help * Thanks!!!

Please help me with my script please. I am trying to do the following: 1. Read files for the current directory 2. Open and read from nbe files files only 3. Read only the lines with the results pattern 4. Split the line and print 3rd field Please indicate what line I need to modify. ... (8 Replies)
Discussion started by: jroberson
8 Replies

10. Shell Programming and Scripting

perl issue ..

hi one perl issue i have xml file with 2 values and one condition b.w them <rule> <val1>12</val1> <cond>and</cond> <val2>13</val2> </rule> i read these values in hash in perl code $one{val1} = 12 $one{cond} = and $one{val2} = 13 now i want to form... (3 Replies)
Discussion started by: zedex
3 Replies
Login or Register to Ask a Question