Here is a more user friendly version of the use statement tester. You can enter the modules you want to test into a textarea box, instead of having to edit the code to test a new use statement. Took way to long to put together as i kept wondering why my box label still was centered even tho i added style="vertical-align:top;". Of course i added it to the textarea td .....

#!/usr/bin/perl # # http://www.perlmonks.org/?node_id=1187481 # use strict; use warnings; use CGI; use HTML::Entities qw/encode_entities/; my $cgi = CGI->new(); print $cgi->header(); print'<head><title>Perl use statment Testing</title></head><body>'."\n +" ; my $uselist0=$cgi->param('uselist'); my $uselist=$uselist0; $uselist='CGI::Carp JSON' unless (defined $uselist); $uselist=~s/[\n\r\t\l]+/ /g; $uselist=~s/\s+/ /g; print '<h3>Testing Use Commands:'.encode_entities($uselist)."</h3>\n"; + print '<pre>'."\n"; for my $use (split(' ',$uselist)) { addin($use); } print '</pre>'."\n"; print '<form method="POST">'."\n"; print '<table><tr>'."\n"; print '<td style="vertical-align:top;">Modules to test<br>CASE MATTERS +!<br>Just like in perl</td>'."\n"; print '<td style="vertical-align:top;"> </td>'."\n"; print '<td style="vertical-align:top;"><textarea rows="10" cols="50" +name="uselist">'.$uselist0.'</textarea></td>'."\n"; print '</tr><tr>'."\n"; print '<td style="vertical-align:top;"><input type="submit" value="Tes +tIt"></td>'."\n"; print '</tr></table> </form>'."\n"; print '</body></html>'; exit; sub addin { my $mod=shift; my $pre=shift; my %inc0=%INC; if ($pre) {print '<pre>'."\n";} print encode_entities('new to %INC from adding use '.$mod.";\n"); eval 'use '.$mod.';' ; print encode_entities("\n".'eval use ERROR:'.$@."\n") if ($@); my %incnew=(); my $max=0; # this ends up as largest in %INC not largest that is new + , good nuf for my $k (keys %INC) { $max=length($k) if (length($k)>$max);} my $fmt=' %-'.$max.'s => %s'."\n"; for my $k (sort keys(%INC)) { print encode_entities(sprintf($fmt,$k,$INC{$k})) unless ($inc0{$k +}); } print "\n"; if ($pre) {print '</pre>'."\n";} }


In reply to Re: pl script in webserver by huck
in thread pl script in webserver by bigup401

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.