Hi,
I've a doubt.
How can i call a subroutine in one perl file from another perl file?.
I've two perl files namely One.pl and Two.pl
Please have a look at the below code.
#file name: One.pl
package MyPerl;
sub Main_Fn
{
# Here i would like to call the subroutine
# ProcessData()in file Two.pl
}
1;
#file name: Two.pl
package Second_Pak;
sub ProcessData
{
# doing some processing here.
}
1;
If we make the second file (Two.pl) as a perl module, then we can invoke the sub ProcessData()as below
#file name One.pl
use Two;
package MyPerl;
sub Main_Fn
{
Two::ProcessData();
}
1;
#file name Two.pm
package Two;
sub ProcessData
{
}
1;
My question is here. Is there any way to call ProcessData without making the second file as perl module.
Thanks,
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.