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

How difficult would it be to modify a site thats using a here-doc to use the template toolkit or some other method? Would it be possible to use ajax on a perl site thats using a here doc? I have an existing perl site which is using a very old version of perl (5.6) I can't upgrade due to module dependencies, however I have a need to be able to hide content, and ajax was suggested as a possible solution. so I have 2 questions 1) is it possible 2 What would I need to get it to work

Replies are listed 'Best First'.
Re: Ajax and Perl 5.6 and heredocs
by Corion (Patriarch) on Mar 05, 2010 at 15:36 UTC

    Both depend on what you already actually know. And it seems you know little about Javascript and Perl.

    Without seeing any of the Perl code, it's hard to tell how easy or difficult modifying it would be. Here-documents usually tie the presentation a bit closer to the program than external templates, but the difference might be very small (one huge here-document) or very large (many tiny here-documents stitched together by much Perl logic).

    If you plan on using Javascript anyway, consider coding the whole "hide" functionality in Javascript. You might or might not need to modify the Perl backend at all if using that approach.

Re: Ajax and Perl 5.6 and heredocs
by jethro (Monsignor) on Mar 05, 2010 at 16:11 UTC

    As Corion said, you are really contemplating two independent tasks.

    Changing the here-doc to template toolkit will help you in the long run to maintain your site and should be rather straightforward (if the source is well-designed). TT has all the important control structures as well, so a 1 to 1 translation is possible

    For the javascript there are a few libraries available that might help you in your task, for example Ext JS, Dojo or jQuery.

Re: Ajax and Perl 5.6 and heredocs
by derby (Abbot) on Mar 05, 2010 at 16:53 UTC

    I'm going to go out on a limb here and assume you're really talking about using a Javascript framework (JQuery, Prototype, Moo, etc) and not necessarily AJAX. The problem probably isn't that your HTML is in here docs but more than likely the HTML is pretty loose and not well structured.

    If you have well structured HTML, injecting JS to make the page more 2.0ish will be a breeze ... it's just that 'here docs' are a big *red flag* that your HTML is probably a mess and will need to be re-written to conform to the more demanding requirements of a JS framework. Template toolkit is not necessarily going to give you that structure either - you can write crappy HTML in template toolkit as well.

    -derby