http://qs321.pair.com?node_id=1162637

glennpm has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know how to INCLUDE these Bootstrap files in a Perl script so I can use the Bootstrap classes for <FORM> elements like Buttons and Text Fields?

I'm struggling to make 2 VERY old perl scripts mobile friendly.

<link type="text/css" rel="stylesheet" href="hideo/bootstrap/css/boots +trap.min.css"> <script type="text/javascript" src="hideo/js-plugin/jquery/jquery-1.10 +.2.min.js"></script> <script type="text/javascript" src="hideo/bootstrap/js/bootstrap.js">< +/script>

Or is there a perl EXPERT that can help me out with these 2 perl scripts written in 1997 to just make the <FORM> elements mobile friendly? I posted this project on Freelancer.com but only 1 person bid on it and now she is not going to do it because she does not understand Bootstrap.

Replies are listed 'Best First'.
Re: Include Bootstrap Files in Perl Script?
by NetWallah (Canon) on May 10, 2016 at 17:07 UTC
    As stated in this stackoverflow query , you should use a CDN, instead of local copies of jquery and bootstrap.

    Here is how I incorporate that in one of my perl scripts:

    print <<"__HEAD__"; Content-Type: text/html <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1 +"> <!-- The above 3 meta tags *must* come first in the head; any othe +r head content must come *after* these tags --> <title>MY Program's title</title> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://code.jquery.com/jquery-2.0.0.js"></script> <!-- Bootstrap V 3.3 CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr +ap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhj +VME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr +ap/3.3.6/css/bootstrap-theme.min.css" integrity= "sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0 +En5r" crossorigin="anonymous"> <!-- Bootstrap V 3.3 JavaScript (Minified)--> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/boot +strap.min.js" integrity= "sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9a +J7xS" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tableso +rter/2.25.1/js/jquery.tablesorter.combined.min.js"> </script> <style> ... __HEAD__
    If you /msg me with your email, I can share a simple perl Bootstrap module that I wrote to help make buttons, dropdowns, alerts and panels. It does not do forms.

            This is not an optical illusion, it just looks like one.

      ++ While I also tend to use CDNs it’s important to note some things: 1) it puts you at the mercy of someone else’s outages and it’s possibly a remote network so it shouldn’t be part of anything meant to be bulletproof or things like bundled webapps that might run in a VPN or intranet with no external access, 2) use Google’s, not jQuery’s or others unless it’s all there is (Google is more reliable, faster, and more likely to be in someone’s cache already), and 3) schemeless URIs are a best practice; so I say. :P

      Thanks Much NetWallah,

      Forgive me for this but is the code you showed in your example in perl? I'm a programmer but mostly on .NET client side and don't understand perl much at all.

      Would it be possible to show me complete .PL perl script showing the Bootstrap includes with the a simple button using the Bootstrap class in a form like below that I could run on my server to get a feel for perl using Bootstrap...

      <form> <input class="btn btn-default" type="submit" value="Order Product" nam +e="submit"> </form>

      I would greatly appreciate it. Thanks, Glenn

        You don't need to do anything special in Perl to include these files. Somewhere in your script it outputs HTML - it may also generate that HTML itself or read it in from an external file or template. What you need to do is find that place in your script and then insert the lines as shown by NetWallah into the output HTML. It could just be copy and paste - no Perl required.

        Hi Glenn,

        Your question is pretty vague. Think about how you would form the question using C# or whichever .NET language you're used to. A better question would be, I have an old Perl script that uses CGI.pm that I need to update to add the following to the output but here is the (sanitized version) script I need to update simplified:

        Your code would go here.  Preferably it would be code that would execute but code snippets can also be used

        Perl is the uber-tool of doing just about anything. There are many many ways of doing something. How to add those css and javascript to your code will depend on what your code looks like, what modules, if any, are being used and whether it uses a template system.

        While we would love to help you, you have to help us help you :)

        Jason L. Froebe

        Tech Blog

        The only "perl" in the code I posted is the "print" statement - the remaining 99% is HTML, and shows how you can incorporate external CDN references to the jquery, bootstrap and tablesorter components.

        It would not be practical to post the 5k line complete script from whence that snippet came.
        Even if I did, it would raise a lot more questions than it answers - it is a hairy mess mixing up HTML, javascript and perl.
        Today, I would not write a mess like that. So I certainly would not want it used as a sample to generate more such monstrosities.

        To get familiar with Bootstrap, you need to work with plain HTML, javascript, jquery and bootstrap.

        Only after you get your head around these, should you approach building your own monstrosity, or messing with someone elses.

        I suggest you follow the advice posted belo this comment, and seek external assistance in getting your project into this decade.

        Good luck.

                This is not an optical illusion, it just looks like one.

Re: Include Bootstrap Files in Perl Script?
by hippo (Bishop) on May 10, 2016 at 16:25 UTC

    Only the HTML needs amending, does it not? This hardly seems like a perl task (in the absence of any posted code suggesting the contrary).

Re: Include Bootstrap Files in Perl Script?
by jellisii2 (Hermit) on May 10, 2016 at 16:11 UTC