Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^6: global var

by tultalk (Monk)
on Apr 06, 2017 at 12:32 UTC ( #1187269=note: print w/replies, xml ) Need Help??


in reply to Re^5: global var
in thread global var

Hi:

Read it was not necessary there. Tried both ways. With $ returns:

Software error:

"$GetLoggedOnId" is not exported by the manageusers module
Can't continue after import errors at update_tables-development.cgi line 30
BEGIN failed--compilation aborted at update_tables-development.cgi line 30.

Padre also says the function in question is not exported by manageusers.

our @EXPORT_OK = qw( &OpenConnection &OpenSession &ProcessLoginRequest &ProcessLostDataRequest &LoginUser &GetLoggedOnId <<<<-------------------

Not posting whole thing to avoid severe criticism from some commenters . etc.

I have many exported other functions and variables and they all work fine. Some are exported, some are not. OpenConnection is exported works fine. CloseConnection not exported and works fine. Both called manageusers::OpenConnection(); and manageusers::CloseConnection();

#--------------------------------------------------------------------- +---------- # Database Conection Functions #--------------------------------------------------------------------- +---------- # FUNCTION: OpenConnection() # DESCRIPTION: Connect to the MySQL database #--------------------------------------------------------------------- +---------- sub OpenConnection { my $localtimenow = localtime(Now()); $dbh = DBI->connect($dsn,$sql_username,$sql_password) or ErrorMessage("Could not connect to the database."); warn("Open Connection-JustBefore returning database handle: '$dbh' + Current Time: '$localtimenow'"); return $dbh; } #--------------------------------------------------------------------- +---------- # FUNCTION: CloseConnection # DESCRIPTION: Disconnect from the MySQL database #--------------------------------------------------------------------- +---------- sub CloseConnection { my $localdbh = @_; my $localtimenow = localtime(Now()); if ($localdbh){ $localdbh->disconnect(); } elsif ($dbh) { $dbh->disconnect(); } warn("Close Connection -just before exit Current Time: '$loca +ltimenow'"); # exit(0); }

Replies are listed 'Best First'.
Re^7: global var
by shmem (Chancellor) on Apr 06, 2017 at 13:15 UTC
    Not posting whole thing to avoid severe criticism from some commenters . etc.

    If you avoid criticism, you avoid learning. If you avoid learning, all you ask is to help you out of a fix. I might do that for some time, but not very long. I'm not going to help you over the road everytime you want to go to the bakery.

    That said, in no post of you in this thread which contains that purported BEGIN block from manageusers does this variable show up. Except in this last one. So things are changing, but I won't play a pointless shell game.

    You need not import a variable from another package to use it. You can use it also fully qualified in your code, in this case as $manageusers::GetLoggedOnId - if this variable really exists in that package (who knows? It looks like you don't either). If it doesn't exist there and you use it anyways, it will be created. Will that be of any use? I don't know and won't guess.

    You could, instead of posting the entire fluff here, stick it onto tultalk's scratchpad. Eventually somebody will look over it and tell you what's wrong.

    Padre also says the function in question is not exported by manageusers.

    • use manageusers qw(GetLoggedOnId) imports a function
    • use manageusers qw($GetLoggedOnId) imports a scalar variable
    • use manageusers qw(%GetLoggedOnId) imports a hash variable
    • ...
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1187269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-06-20 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (94 votes). Check out past polls.

    Notices?