- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- using perl modules
Operating System - Linux
1754020
Members
7074
Online
108811
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
01-24-2007 08:21 AM
01-24-2007 08:21 AM
using perl modules
I am having difficulty using perl modules, I know once I start and figure this out, it would make my life simplier.
My module is used for logging into a database.
#!/usr/bin/perl
use strict;
use warnings;
package login_acdb;
my $file = "/etc/accesscare/$ENV{'ORACLE_SID'}/voice/ac.login";
open LOGINID, "< $file" or die "Could not open $file: $!";
my $oraLoginId =;
chomp $oraLoginId;
1;
The file looks like: oracle/oracle321
I have added it to my PERL5LIB environment so it is in the @INC path.
But now I am having problems with how to call it.
Here is where I call it in my script:
sub doSqlSelect {
my @buffer = qx { sqlplus -S $login_acdb::oraLoginId < set heading off
set pagesize 0
set feedback off
SELECT feature||','||description
FROM vt_feature
ORDER by 1;
EOF
};
Yes, I know it would be really easy to use the DBI, but I have tried to no success to have 32 bit oracle, with 32 or 64 bit perl, on HP 11.00 RISC. Spent a week on that one.
DBI goes in nice, but DBD::ORACLE cacks out every time
My module is used for logging into a database.
#!/usr/bin/perl
use strict;
use warnings;
package login_acdb;
my $file = "/etc/accesscare/$ENV{'ORACLE_SID'}/voice/ac.login";
open LOGINID, "< $file" or die "Could not open $file: $!";
my $oraLoginId =
chomp $oraLoginId;
1;
The file looks like: oracle/oracle321
I have added it to my PERL5LIB environment so it is in the @INC path.
But now I am having problems with how to call it.
Here is where I call it in my script:
sub doSqlSelect {
my @buffer = qx { sqlplus -S $login_acdb::oraLoginId <
set pagesize 0
set feedback off
SELECT feature||','||description
FROM vt_feature
ORDER by 1;
EOF
};
Yes, I know it would be really easy to use the DBI, but I have tried to no success to have 32 bit oracle, with 32 or 64 bit perl, on HP 11.00 RISC. Spent a week on that one.
DBI goes in nice, but DBD::ORACLE cacks out every time
- Tags:
- Perl
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 10:48 PM
01-24-2007 10:48 PM
Re: using perl modules
Hi,
The problem seems to be that the variable $oraLoginID that you defined in your package login_acdb was declared as lexical (by my).
You can never access lexical variables once they are out of scope (especially from a different package, viz. the importing one).
Although this is usually the wished behavior in order to prevent name collisions, in you case it isn't.
Thus, you must declare it as a package global.
Only then does it appear in the symbol table,
and can always be accessed by its full qualified name (i.e. prepending the package that defined it).
This takes usually place for *every* variable that you introduce without explicit declaration unless you use the strict pragma.
But we usually want to remain under strict vars (to avoid name collisions).
Therefore declare it as "our" instead of "my".
In the importing package you could then access it by $login_acdb::ora_LoginId.
If this gets too clumsy you could also "alias" the variable by using the glob reference notation whithin a short block where you relinquish the strict refs pragma by "no strict 'refs';".
This should be the only circumstance where the use of the so called symbolic refs is "approved" by style guides.
Please, see the examples in "perldoc perlref" for details.
Alternatively you could use the Exporter module and declare the variables that you want to "alias" in the @EXPORT array (which causes automatic, but mostly deprecated import into the using name space), or better yet in the @EXPORT_OK array (where the importer has to explicitly declare what he wishes to be imported, usually in an appended qw() list).
More or less the Exporter module is doing the messing with the symbol table behind the scenes for the user.
See "perldoc Exporter" for details.
The problem seems to be that the variable $oraLoginID that you defined in your package login_acdb was declared as lexical (by my).
You can never access lexical variables once they are out of scope (especially from a different package, viz. the importing one).
Although this is usually the wished behavior in order to prevent name collisions, in you case it isn't.
Thus, you must declare it as a package global.
Only then does it appear in the symbol table,
and can always be accessed by its full qualified name (i.e. prepending the package that defined it).
This takes usually place for *every* variable that you introduce without explicit declaration unless you use the strict pragma.
But we usually want to remain under strict vars (to avoid name collisions).
Therefore declare it as "our" instead of "my".
In the importing package you could then access it by $login_acdb::ora_LoginId.
If this gets too clumsy you could also "alias" the variable by using the glob reference notation whithin a short block where you relinquish the strict refs pragma by "no strict 'refs';".
This should be the only circumstance where the use of the so called symbolic refs is "approved" by style guides.
Please, see the examples in "perldoc perlref" for details.
Alternatively you could use the Exporter module and declare the variables that you want to "alias" in the @EXPORT array (which causes automatic, but mostly deprecated import into the using name space), or better yet in the @EXPORT_OK array (where the importer has to explicitly declare what he wishes to be imported, usually in an appended qw() list).
More or less the Exporter module is doing the messing with the symbol table behind the scenes for the user.
See "perldoc Exporter" for details.
Madness, thy name is system administration
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP