Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: global var

by stevieb (Canon)
on Apr 05, 2017 at 21:01 UTC ( [id://1187187]=note: print w/replies, xml ) Need Help??


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

See GotToBTru's post to create a proper example, but from your code, I see this:

# exported functions

That makes me think you copy/pasted something off of the Internet, and with the lines that follow that comment, it appears it closely resembles perl4 code (or someone coding perl5 that hasn't migrated to the perl5 mindset yet. This was nearly two decades ago!).

I feel that you need some new resources to read, research and reflect upon. Is this a project that you were forced into and are trying to adjust by chance?

Replies are listed 'Best First'.
Re^4: global var
by tultalk (Monk) on Apr 05, 2017 at 21:18 UTC

    I feel that you need some new resources to read, research and reflect upon. Is this a project that you were forced into and are trying to adjust by chance?

    Yes. From 2003

Re^4: global var
by tultalk (Monk) on Apr 05, 2017 at 21:43 UTC

    Hi: Don't we all cut and paste from the internet or our own old code or code on CD's that come with textbooks? Yes we do.

    use manageusers qw(LoggedOn_user_id);

    Software error:

    "LoggedOn_user_id" 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.
    

    BEGIN { use vars qw($VERSION @ISA @EXPORT); use DBI; # $ENV{DBI_TRACE}=1; # $ENV{PERL_DBI_DEBUG}=1; require Exporter; @ISA = qw(Exporter); # exported functions our @EXPORT_OK = qw( &OpenConnection &OpenSession &ProcessLoginRequest &ProcessLostDataRequest &LoginUser &decodeEncryptedPassName &UpdateUserData &GetUserLostData &LogoutUser &GetUserSessionCookie &CheckForAuthorizedUser &Expires $attempts $adminaccess $LoggedOn_user_id <<<<<<---------------------- &Now &CheckValidLoginChar &CheckValidEmailChar &print_md5_javascript); $VERSION = '0.0.1'; }

      What you are trying to import is not a function.

      - use manageusers qw(LoggedOn_user_id); + use manageusers qw($LoggedOn_user_id);
      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

        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); }

      "Don't we all cut and paste from the internet or our own old code or code on CD's that come with textbooks? Yes we do."

      No. We don't. Especially stuff from 2003.

      Things change rapidly in the tech world. You can not build something for today's world using something that came from over a decade ago, no matter what.

      You can not expect something from 2003 to act and behave today like it did then. Even in 2003, the code you've posted was outdated. If you are creating something new, you'll need to get up-to-speed on today's technology. Being an auto-mechanic by trade (but out of the industry for many years), it's like showing an example of a carburetor from a vehicle, while asking for help on a brand new fuel injected, computerized ride. I'm also a licensed residential electrician by trade, and asking about the expansion of aluminum wires in a copper socket in today's world would also be akin.

      Help may come, but with 14 year old code, you're pretty much going to be kicking a dead horse (imho).

      To further, the code you did post was broken horribly, and wouldn't even compile back then. Even on the node I'm replying to, you still close off with a brace where a parens is required.

        Hi again:

        It is not closing off with a brace where a paren is required. The Brace is closing the Begin The paren is closing this: our @EXPORT_OK = qw(

        BEGIN { use vars qw($VERSION @ISA @EXPORT); use DBI; # $ENV{DBI_TRACE}=1; # $ENV{PERL_DBI_DEBUG}=1; require Exporter; @ISA = qw(Exporter); # exported functions our @EXPORT_OK = qw( &OpenConnection &OpenSession &ProcessLoginRequest &ProcessLostDataRequest &LoginUser &decodeEncryptedPassName &UpdateUserData &GetUserLostData &LogoutUser &GetUserSessionCookie &CheckForAuthorizedUser &Expires $attempts $adminaccess $LoggedOn_user_id <<<<<<---------------------- &Now &CheckValidLoginChar &CheckValidEmailChar &print_md5_javascript); $VERSION = '0.0.1'; }

        I also changed $LoggedOn_user_id to a function call &GetLoggedOn_user_id to deliver the number to the other module and it still does not work.

        And yes it compiles then and now.

        Your comments and those of some others are very discouraging to one who is having fun and enjoying this resurrection. A little tolerance is in order I think.

        I realize there is much stuff here that is old and discouraged but it still works.

        You're using perl, its very old, people still use perls from 14 years ago , so as a general argument that old code is dead code its super weak argument ... but thats completely unrelated to the less than spaghetti code tultalk is trying to polish with little understanding

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-24 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found