- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need simple perl example of creating, executing an...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2002 04:38 AM
тАО07-03-2002 04:38 AM
1 - Create a perl module that will provide a list of entries from a file using perl.
2 - Module will ask user to select an entry from the file.
3 - Data from the file will be returned from the module to the calling program.
I'm kind looking to see what I would need to do to code a module and be able to access the module expecting to make further decisions depending upon the results results.
jack...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2002 06:56 AM
тАО07-03-2002 06:56 AM
Re: Need simple perl example of creating, executing and returning information from a perl module
at the shell type
perldoc perlmod
perldoc perlmodlib
for howto open files, and read/write data
perldoc perlopentut
and if your module shall be OO
perldoc perlboot
perldoc perltoot
perldoc perltootc
These will give you enough to get started.
You have to decide whether your module will follow procedural or object oriented design.
For the first it's easiest to let your Module inherit from the Exporter module.
Don't be afraid, there's not much more OO involved than assigning the @ISA array:
require Exporter;
@ISA = qw(Exporter);
For the latter (viz. OO design) you will have to write a constructor (aka class method) that uses the bless() function.
With it you "bless" any data structure (preferably a hashref) to your package's namespace.
Then you have to write accessor methods (ordinary subs that take an object ref as 1st argument) to deal with your "encapsulated" data.
The rest is ordinary Perl idioms (OO purists will cry out ;-)
It is important that your module returns any true value.
The Perl idiom for this requirement is a
1;
as last statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2002 05:59 AM
тАО07-29-2002 05:59 AM
Re: Need simple perl example of creating, executing and returning information from a perl module
Thanks for the pointers... When I get back to it, I'll follow your suggestions.
Thanks for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2002 03:05 PM
тАО07-29-2002 03:05 PM
Re: Need simple perl example of creating, executing and returning information from a perl module
trying to read? A tab-delimited flat text file? A binary file? A
database?
The second part is a little easier (assuming you want
to get the user's reponse from stdin (i.e. the keyboard)):
print("what entry do you want?\n");
$entry = <>;
If you want to get fancy and provide command line
editing at the prompt, check out the Perl module
Term::Readline.
The last part, like the first part, depends on the
type of file.
As for "module", if you mean a real Perl module
with the "::" business and all that OO-ish stuff,
definitely read "perldoc permod" or "man perlmod".
It has an example of setting up a module.
If you have just learned Perl it might be better to
first create a set of plain Perl subroutines and worry
about packaging them into a module later.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2002 04:21 AM
тАО07-30-2002 04:21 AM
Re: Need simple perl example of creating, executing and returning information from a perl module
I have a piece of code that acts as a menu for selecting entries from a file. This same code is used by multiple scripts. I wanted to turn the menuing code into a module so that I could call the module and then use the result returned from the module. I would pass the program name of the calling program to the menu module.
jack...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2002 04:37 AM
тАО07-30-2002 04:37 AM
Solutionthean use
'use my_module;'
inside your own script, and the *complete* file is included into your current script (package main)
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2002 04:42 AM
тАО07-30-2002 04:42 AM
Re: Need simple perl example of creating, executing and returning information from a perl module
Thanks for the help.
jack...