Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Perl Modules

by jamroll (Beadle)
on Jun 21, 2017 at 18:23 UTC ( #1193225=note: print w/replies, xml ) Need Help??


in reply to Re^4: Perl Modules
in thread Perl Modules

nope! things don't seem to be meshing nicely....

and oh no! @INC will no longer include .! That's inconvenient. But, not impossible to move my modules to a folder in @INC

Pm::Redir is claiming pre_html_header() isn't defined - this routine is found in Pm::Html

the subs Pm::Redir::redir and Pm::Redir::redir3 both call Pm::Html::pre_html_header()

now granted, Pm::Html does use a bunch of other modules i've created. i haven't checked those modules to see if they include Pm::Redir, but would it matter if Pm::Html uses a module which then includes Pm::Redir??

here's the code:

just the header to ./Pm::Html
package Pm::Html; #/ # functions for displaying HTML elements #/ my $DEBUGGER = 0; my $TABLE_BORDER = "0"; ######################## use strict; use warnings; use Exporter; use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); use URI::Escape; ######################## use Pm::Bc_chef qw(cookie_get); use Pm::Bc_sql qw(get_race_asWord get_zodiacs get_themes get_constant get_theme_data get_config get_cities get_countries sql_execute get_users get_site_name get_home_page user_exists get_location get_phrase ); use Pm::Bc_misc qw(get_param add_numeric_suffix shorten_str ); use Pm::Date qw(expand_date determine_zodiac get_today get_month ); use Pm::Search qw(search_terms); use Pm::User qw(get_user_stats get_user_friend_requests get_user_blocked_users get_user_unread_messages get_user_stat get_user_fuck_alert_count get_user_pic get_user_dp get_user_stats_asIcons get_user_friends ); ######################## our $VERSION = 1.00; our @ISA = qw(Exporter); our @EXPORT_OK = qw( _tests pre_html_header header footer table fieldset fieldset_constricted div tdata trow radio checkbox textarea unordered_list ordered_list li href img dropdown input display_404_page display_about_page display_chat display_city_names display_city_names_asDropdown display_country_names display_country_names_asDropdown display_forgot_page display_blocked display_friends display_fuck_me_alerts display_homepage display_mail display_navbar display_pay_page display_photos_page display_searchbar display_signup_page display_stats_page display_theme_names display_theme_names_asDropdown display_titlebar display_todays_birthdays display_user_card display_user_card_mini display_user_list display_admin_page display_admin_ustats_editor display_admin_uphotos_editor display_admin_uflags_editor display_admin_umsgs_editor display_years_forDropdowns display_users_forDropdowns display_config_forDropdowns display_zodiac_icon display_debug_one display_debug_many display_debug_code display_debug_large get_config_forDropdowns :debug ); %EXPORT_TAGS = ( debug => [qw(display_debug_one display_debug_many disp +lay_debug_code display_debug_large _tests)], ); ########################
and the Pm::Redir code:
package Pm::Redir; #/ # Client Redirections #/ use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use URI::Escape; use Exporter; use vars qw($VERSION @ISA @EXPORT_OK); use Pm::Bc_chef qw(cookie_set); use Pm::Html qw(display_debug_one display_debug_many display_debug_code display_debug_large pre_html_header ); # i'm not using :debug cuz that don't work either! $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT_OK = qw( _tests redir redir3 error_redir notice_redir ); ############################## sub redir($$) { #* # redirects a client browser to a specified URL (may include a msg) #* my ($url, $msg) = @_; # a url to redirect to && a msg my $html = pre_html_header(); $html =~ s/content-type\: text\/html\n\n//i; if ($msg) { $html .= "status: 302 $msg\n"; } else { $html .= "status: 302 redir ok\n"; } $html .= "location: $url\n\n"; return $html; # a scalar #usage print redir("/", "invalid page"); } ############################## sub redir3($$$) { #* # redirects a client browser to a specified URL (may include a msg) # can add a cookie to the redirect (for errors or msgs or other thin +gs you deem necessary) # this is NOT version 3 of the redir command. it's a 3 param comman +d! #* my ($url, $msg, $type) = @_; # a url to redirect to && a msg && a ms +g type ('e' or 'n', or whatever else you like) my $html = ""; if ($type) { $html = cookie_set($type, $msg, 0); } my $html .= pre_html_header(); $html =~ s/content-type\: text\/html\n\n//i; $msg = uri_escape($msg); $html .= "status: 302 $msg\n"; $html .= "location: $url\n\n"; return $html; # a scalar #usage: print redir3("/", "Access Denied by redir3", 'e') } ############################## sub error_redir($$) { #* # redirects a client browser to a specified URL (may include a msg) # adds an 'error' cookie to the redirect #* my ($url, $msg) = @_; # a url to redirect to && a msg my $html = redir3($url, $msg . " by?", 'e'); return $html; # a scalar #usage: print error_redir("/subscribe.pl", "you must subscribe to ac +cess this area"); } ############################## sub notice_redir($$) { #* # redirects a client browser to a specified URL (may include a msg) # adds a 'notice' cookie to the redirect #* my ($url, $msg) = @_; # a url to redirect to && a msg my $html = redir3($url, $msg, 'n'); return $html; # a scalar #usage: print notice_redir("/', "file updated!"); } ############################## sub _tests(;$) { #* # to test all <i>Pm::Redir</i> functions #* my ($extended) = @_; # show extended data (optional) my $rv = ""; my $loggedin = cookie_get("loggedin"); my $test = ""; my $test2 = ""; my $test3 = ""; my $db = sql_connect("ns.db"); if ($db) { $test = "/index.pl"; $test2 = "Test Redirection"; $test3 = "n"; $rv .= display_debug_code("error_redir(\"$test\", \"$test2\")", er +ror_redir($test, $test2)); $rv .= display_debug_code("notice_redir(\"$test\", \"$test2\")", n +otice_redir($test, $test2)); $rv .= display_debug_code("redir(\"$test\", \"$test2\")", redir($t +est, $test2)); $rv .= display_debug_code("redir3(\"$test\", \"$test2\", \"$test3\ +")", redir3($test, $test2, $test3)); } else { $rv .= "DB connection error!<br>\n"; } return $rv; # a scalar of the results of all tests #usage: print _tests(); } ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## 1;

Replies are listed 'Best First'.
Re^6: Perl Modules
by tobyink (Canon) on Jun 21, 2017 at 18:45 UTC

    Cycles in use statements can cause issues. Often hard-to-diagnose problems.

    Breaking the cycle by making one of them a just-in-time require instead of a use is often a good solution.

    # AAA.pm package AAA; use base 'Exporter'; our @EXPORT = qw(aaa); use BBB qw(bbb); sub aaa { my $arg = shift; return 0 if $arg <= 0; return 1 + bbb($arg - 1); } 1; # BBB.pm package BBB; use base 'Exporter'; our @EXPORT = qw(bbb); # use AAA qw(aaa); sub bbb { my $arg = shift; return 0 if $arg <= 0; require AAA; return 1 + AAA::aaa($arg - 1); } 1; # main.pl use AAA; use BBB; print aaa(3) + bbb(4), "\n";

Log In?
Username:
Password:

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

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












    Results (69 votes). Check out past polls.

    Notices?