<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Execute a PERL Module as a Normal Script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102986#M92450</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;   In Linux i tried to execute a Perl Script&lt;BR /&gt;that calls a subroutine defined in another file which i am including as a package in the main perl script.&lt;BR /&gt;&lt;BR /&gt;   Now my question is can i execute this Perl module having the function defined as a Perl Script.&lt;BR /&gt;&lt;BR /&gt;   Also can i execute the Package as a stand alone Script if the package in turn calls a function defined in Some other file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ex -&lt;BR /&gt;&lt;BR /&gt;   Main.pl&lt;BR /&gt;   &lt;BR /&gt;   #!/usr/bin/perl&lt;BR /&gt;   use Pack1; &lt;BR /&gt;    Pack1::FirstRoutine();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    Pack1 File looks as below&lt;BR /&gt;&lt;BR /&gt;    package Pack1;&lt;BR /&gt;    use Pack2;&lt;BR /&gt;&lt;BR /&gt;    sub FirstRoutine&lt;BR /&gt;     {&lt;BR /&gt;        print "\n I am in first Package\n";}&lt;BR /&gt;     Pack2::SecondRoutine();&lt;BR /&gt;&lt;BR /&gt;Pack2 File looks as below&lt;BR /&gt;&lt;BR /&gt;package Pack2;&lt;BR /&gt;   sub SecondRoutine&lt;BR /&gt;     {&lt;BR /&gt;        print "\n I am in Second Package\n";}&lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;   Now i want to execute the Pack1.pm file directly&lt;BR /&gt;&lt;BR /&gt;   Can any one help me out of this &lt;BR /&gt;&lt;BR /&gt;thnaks in advance&lt;BR /&gt;Vikram       &lt;BR /&gt;</description>
    <pubDate>Thu, 15 Nov 2007 07:02:08 GMT</pubDate>
    <dc:creator>CA1490051</dc:creator>
    <dc:date>2007-11-15T07:02:08Z</dc:date>
    <item>
      <title>How to Execute a PERL Module as a Normal Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102986#M92450</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;   In Linux i tried to execute a Perl Script&lt;BR /&gt;that calls a subroutine defined in another file which i am including as a package in the main perl script.&lt;BR /&gt;&lt;BR /&gt;   Now my question is can i execute this Perl module having the function defined as a Perl Script.&lt;BR /&gt;&lt;BR /&gt;   Also can i execute the Package as a stand alone Script if the package in turn calls a function defined in Some other file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ex -&lt;BR /&gt;&lt;BR /&gt;   Main.pl&lt;BR /&gt;   &lt;BR /&gt;   #!/usr/bin/perl&lt;BR /&gt;   use Pack1; &lt;BR /&gt;    Pack1::FirstRoutine();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    Pack1 File looks as below&lt;BR /&gt;&lt;BR /&gt;    package Pack1;&lt;BR /&gt;    use Pack2;&lt;BR /&gt;&lt;BR /&gt;    sub FirstRoutine&lt;BR /&gt;     {&lt;BR /&gt;        print "\n I am in first Package\n";}&lt;BR /&gt;     Pack2::SecondRoutine();&lt;BR /&gt;&lt;BR /&gt;Pack2 File looks as below&lt;BR /&gt;&lt;BR /&gt;package Pack2;&lt;BR /&gt;   sub SecondRoutine&lt;BR /&gt;     {&lt;BR /&gt;        print "\n I am in Second Package\n";}&lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;   Now i want to execute the Pack1.pm file directly&lt;BR /&gt;&lt;BR /&gt;   Can any one help me out of this &lt;BR /&gt;&lt;BR /&gt;thnaks in advance&lt;BR /&gt;Vikram       &lt;BR /&gt;</description>
      <pubDate>Thu, 15 Nov 2007 07:02:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102986#M92450</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-11-15T07:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Execute a PERL Module as a Normal Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102987#M92451</link>
      <description>Hi Vikram:&lt;BR /&gt;&lt;BR /&gt;I'm not sure I understand.  The Perl module is the fundamental building block of code re-use with 'use' and 'require' controlling its incorporation.&lt;BR /&gt;&lt;BR /&gt;Too, your Perl program can call external entities via 'system' or by using 'backticks', and then there are 'piped' open() methods, too, to connect external programs.&lt;BR /&gt;&lt;BR /&gt;By more direct answer to your question, "Now I want to executre the Pack1.pm file directly": Why can't it be a standalone module that you reuse as needed?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Nov 2007 08:33:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102987#M92451</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-15T08:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Execute a PERL Module as a Normal Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102988#M92452</link>
      <description>You could "do" an external Perl script&lt;BR /&gt;(see perldoc -f do; perldoc perlmod).&lt;BR /&gt;But real Perl modules simply aren't meant&lt;BR /&gt;to be executed stand-alone.&lt;BR /&gt;They are instead intended to be loaded&lt;BR /&gt;by a "use" or "require" into the callers namespace.&lt;BR /&gt;But this has already been mentioned by James.&lt;BR /&gt;&lt;BR /&gt;If your module follows a more procedural approach then the Exporter module can very much ease the controlled import of vars, subs, handles, whatever without necessarily cluttering the caller's namespace.&lt;BR /&gt;&lt;BR /&gt;On the other hand, a pure object oriented module doesn't require this conventional import of types (in fact even shouldn't at all) but instead should offer a constructor (whose guise in Perl lacks the usual formality of "real" OO languages, and only by convention often is called new()), accessor methods and other object methods.&lt;BR /&gt;&lt;BR /&gt;If you don't like reading the excellent POD regarding modules and OO, as well as tutorials, (type "perldoc perl" to get a list),&lt;BR /&gt;then I would suggest getting a good book that treats these things.&lt;BR /&gt;Not to mention the notorious Camel Book,&lt;BR /&gt;I would suggest getting a copy of "Intermediate Perl" by Schwart and Foy&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.oreilly.com/catalog/intermediateperl/" target="_blank"&gt;http://www.oreilly.com/catalog/intermediateperl/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;No, I don't get a commission by O'Reilly ;-)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Nov 2007 12:16:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-execute-a-perl-module-as-a-normal-script/m-p/4102988#M92452</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-11-15T12:16:59Z</dc:date>
    </item>
  </channel>
</rss>

