RE: Calling subroutine from different file
Mujju, Try using the require statement in call.pl Example call.pl C:\perl\bin\perl.exe #some script my $cnt=0; sub do_something { . . . } ### Main require c:\perl\script\file1.pl; require c:\perl\script\file2.pl; do something else; do_something; print something\n; exit 0; now file1.pl --- sub file1 { do stuff here; . . } 1; From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Perl Perl Sent: Wednesday, March 11, 2009 12:50 PM To: perl-win32-users@listserv.activestate.com Subject: Calling subroutine from different file Dear All, I have coded few scripts as mentioned below. My aim is to call the files and function without using a extra file ( call.pl as mentioned below) and with the single click. I have two files, file1.pl file2.pl In above files, I will call the common subroutine ( say code_send() ) which is located in fun.pl . Now my task is to execute the above scripts in one click. So I thougt to create a file by name call.pl here in this file I will add two system calls as below. system(perl file1.pl); system(perl file2.pl); I hope there is a better way to do this. If it is then please help me. Regards, Mujju ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Calling subroutine from different file
Thanks David for your prompt reply. I have done that, but I want to avoid using call.pl here, or atleaset would like to avoid number of files. It is for sure that, I should use file1.pl and file2.pl, because these two files are working on different kind of data. Hope I am clear here. On 3/11/09, David M. Funk mf...@trinitysol.net wrote: Mujju, Try using the require statement in call.pl Example call.pl C:\perl\bin\perl.exe #some script my $cnt=0; sub do_something { . . . } ### Main require c:\perl\script\file1.pl; require c:\perl\script\file2.pl; do something else; do_something; print “something\n”; exit 0; now file1.pl --- sub file1 { do stuff here; . . } 1; *From:* perl-win32-users-boun...@listserv.activestate.com [mailto: perl-win32-users-boun...@listserv.activestate.com] *On Behalf Of *Perl Perl *Sent:* Wednesday, March 11, 2009 12:50 PM *To:* perl-win32-users@listserv.activestate.com *Subject:* Calling subroutine from different file Dear All, I have coded few scripts as mentioned below. My aim is to call the files and function without using a extra file ( call.pl as mentioned below) and with the single click. I have two files, file1.pl file2.pl In above files, I will call the common subroutine ( say code_send() ) which is located in fun.pl . Now my task is to execute the above scripts in one click. So I thougt to create a file by name *call.pl* here in this file I will add two system calls as below. system(perl file1.pl); system(perl file2.pl); I hope there is a better way to do this. If it is then please help me. Regards, Mujju -- -- Regards, Mujju ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Calling subroutine from different file
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Perl Perl Sent: 11 March 2009 16:50 To: perl-win32-users@listserv.activestate.com Subject: Calling subroutine from different file Dear All, I have coded few scripts as mentioned below. My aim is to call the files and function without using a extra file ( call.pl as mentioned below) and with the single click. I have two files, file1.pl file2.pl In above files, I will call the common subroutine ( say code_send() ) which is located in fun.pl . Put common functions in a module, for example, If the file CommonFunctions.pm contained the following: - use strict; use warnings; package CommonFunctions; use base qw{Exporter}; our @EXPORT_OK = qw{code_send}; sub code_send { print This is code_send\n; } 1; - Any scripts that want to use that function will include: - use CommonFunctions qw{code_send}; ... code_send(); - See 'perldoc perlmod' for documentation on Perl modules, and 'perldoc Exporter' on exporting symbols from modules. Now my task is to execute the above scripts in one click. So I thougt to create a file by name call.pl here in this file I will add two system calls as below. system(perl file1.pl); system(perl file2.pl); I hope there is a better way to do this. If it is then please help me. I'm not sure that I understand what you are asking. Unless it is feasible to put the code from file1.pl and file2.pl into a single file, the executing them in sequence seems a reasonable thing to do. HTH -- Brian Raven --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs