Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^6: How do I go from procedural to object oriented programming?

by Lady_Aleena (Priest)
on Apr 22, 2015 at 18:27 UTC ( [id://1124298]=note: print w/replies, xml ) Need Help??


in reply to Re^5: How do I go from PROCEDURAL to object oriented programming?
in thread How do I go from procedural to object oriented programming?

Anonymous Monk, using other people's objects is easier than writing them which takes a very different mind set from what I have now. What else should I use for my params if CGI is on its way out? I have not seen any suggested substitutes for CGI's param.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena
  • Comment on Re^6: How do I go from procedural to object oriented programming?

Replies are listed 'Best First'.
Re^7: How do I go from procedural to object oriented programming?
by Anonymous Monk on Apr 22, 2015 at 22:17 UTC
    I am not the Anonymous Monk that was attacking jeffa for using Moose. Did you know that CGI.pm has been removed from the Perl core? This means that your hosting provider could one day perform a major upgrade that results in you no longer having access to the CGI.pm they provide for you today. Now is the time to find alternatives: CGI::Alternatives.

    Maybe all you need is CGI::Lite.

      Anonymous Monk, I am aware CGI has been removed from the core. If my web host does upgrade, I will first go into shock then second go to work replacing CGI with whichever module is its clear successor. I looked over the alternatives and saw param/params listed in Dancer, but I'm not too clear on how to use Dancer's param.

      CGI::Lite does not seem to have a param option, neither does Plack, which has been mentioned by others in this discussion.

      I am at the ready to change use CGI; to whichever module is the easiest to use. Below are the lines where I use CGI's param. I am at the ready to do a find/replace in the 15 scripts where I use it, if someone would be kind enough to get me started in the right direction.

      use CGI; use CGI::Carp qw(fatalsToBrowser); use HTML::Entities qw(encode_entities); my $cgi = CGI->new; # in Movies/Movie_by_alpha.pl my $year = $cgi->param('year') ? encode_entities($cgi->param('ye +ar'), '<>"') : ''; my $media = $cgi->param('media') ? encode_entities($cgi->param('me +dia'), '<>"') : ''; my $format = $cgi->param('format') ? encode_entities($cgi->param('fo +rmat'), '<>"') : ''; my $genre = $cgi->param('genre') ? encode_entities($cgi->param('ge +nre'), '<>"') : ''; my $basis = $cgi->param('based on') ? encode_entities($cgi->param('ba +sed on'), '<>"') : ''; my $title = $cgi->param('title') ? encode_entities($cgi->param('ti +tle'), '<>"') : ''; # in Movies/Movies_by_genre.pl my $select = encode_entities($cgi->param('genre'),'<>"'); # in Movies/Movies_by_series.pl my $select = encode_entities($cgi->param('series'),'<>"'); # in Role_playing/Magic_items/spell_scrolls.pl my $select = encode_entities($cgi->param('spell scroll'),'<>"'); # in Role_playing/Miscellany/Character_mutations_generator.pl my $iterations = $cgi->param('iterations') ? encode_entities($cgi->par +am('iterations'),'<>"') : 1; # in Role_playing/Miscellany/Word_finds.pl my $select = encode_entities($cgi->param('word find'),'<>"'); # in Role_playing/Monsters/index.pl my $select = $cgi->param('monster') ? encode_entities($cgi->param('mon +ster'),'<>"') : undef; # in Role_playing/Player_characters/Spellbooks.pl my $select = encode_entities($cgi->param('spellbook'),'<>"'); # in Role_playing/Reference_tables/Proficiencies.pl my $alpha = $cgi->param('alpha') ? encode_entities($cgi->param('alph +a'),'<>"') : ''; my @classes = $cgi->param('class') ? $cgi->param('class') : ''; # can' +t encode entities or array won't work. my $slots = $cgi->param('slots') ? encode_entities($cgi->param('slot +s'),'<>"') : ''; my $ability = $cgi->param('rel_ability') ? encode_entities($cgi->param +('rel_ability'),'<>"') : ''; # in Role_playing/Reference_tables/Weapons.pl my $broad = $cgi->param('broad') ? encode_entities($cgi->param('broad' +),'<>"') : ''; my $tight = $cgi->param('tight') ? encode_entities($cgi->param('tight' +),'<>"') : ''; # in working/Twitter/Follower_check.pl my $follower = encode_entities($cgi->param('follower'),'<>"'); my $outreach = encode_entities($cgi->param('outreach'),'<>"'); # in working/Twitter/Tweet_a_message.pl # can't encode entities on arrays since they won't work. my @account_select = $cgi->param('account_select'); my @list_select = $cgi->param('list_select'); my $tweet = encode_entities($cgi->param('tweet'),'<>"'); # in working/Twitter/Twitter_lists_properties.pl my $sort_by = encode_entities($cgi->param('sort'),'<>"'); # in working/Twitter/Twitter_mentions.pl my $select = encode_entities($cgi->param('accounts'),'<>"'); # in working/Twitter/Twitter_people.pl my $select = encode_entities($cgi->param('accounts'),'<>"');

      Update 1: I am doing this now to hopefully get the discussion about procedural to object oriented programming back on track.

      Update 2: I do not know if any of the current CGI alternative modules have a perl version restriction. The perl on my web host is 5.8.8. If any of them require a higher perl, you can skip it.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        Dancer:
        my $username = param "user"; my $password = param "pass";
        CGI::Lite:
        $form = $cgi->parse_form_data; %form = $cgi->parse_form_data; # or $form = $cgi->parse_form_data ('GET', 'HEAD' or 'POST');
        Plack::Request:
        my $query = $req->parameters;
        CGI::Minimal:
        my $form_field_value = $cgi->param('some_field_name');

        But the more that one studies your website, the more one comes to the conclusion that Wordpress does everything you need. What you currently have is a chaotic mess of home rolled substitutions of antiquated technology. All the work you put in up to this point has served to teach you. Now you can move on. You would be well advised to start over and store your data in a database. Again, Wordpress does all of this for you. You can always write Perl scripts to import your current data into Wordpress documents. You would gain a lot of features, for example your audience would be able to log in and comment just like you do here.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found