Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I just fell face forward into this earlier today (sorry for the extremely long lines):
use vars qw/ + + $AllowFullYearView + + $LevelForRobotsDetection $LevelForWormsDetection $LevelForBrowsersDete +ction $LevelForOSDetection $LevelForRefererAnalyze + $LevelForFileTypesDetection $LevelForSearchEnginesDetection $LevelForK +eywordsDetection + /; ($AllowFullYearView, $LevelForRobotsDetection, $LevelForWormsDetection, $LevelForBrowsersD +etection, $LevelForOSDetection, $LevelForRefererAnalyze, $LevelForFileTypesDetection, $LevelForSearchEnginesDetection, $LevelF +orKeywordsDetection)= (2,2,0,2,2,2,2,2,2); use vars qw/ + + $DirLock $DirCgi $DirConfig $DirData $DirIcons $DirLang $AWScript $Arc +hiveFileName + $AllowAccessFromWebToFollowingIPAddresses $HTMLHeadSection $HTMLEndSec +tion $LinksToWhoIs $LinksToIPWhoIs + $LogFile $LogType $LogFormat $LogSeparator $Logo $LogoLink $StyleSheet + $WrapperScript $SiteDomain + $UseHTTPSLinkForUrl $URLQuerySeparators $URLWithAnchor $ErrorMessages +$ShowFlagLinks + /; ($DirLock, $DirCgi, $DirConfig, $DirData, $DirIcons, $DirLang, $AWScri +pt, $ArchiveFileName, $AllowAccessFromWebToFollowingIPAddresses, $HTMLHeadSection, $HTMLEnd +Section, $LinksToWhoIs, $LinksToIPWhoIs, $LogFile, $LogType, $LogFormat, $LogSeparator, $Logo, $LogoLink, $Sty +leSheet, $WrapperScript, $SiteDomain, $UseHTTPSLinkForUrl, $URLQuerySeparators, $URLWithAnchor, $ErrorMessa +ges, $ShowFlagLinks)= ('','','','','','','','','','','','','','','','','','','','','','','' +,'','','','');
etc for several pages, followed by:
#--------------------------------------------------------------------- +--------- + # Function: Write on ouput header of HTML page + + # Parameters: None + + # Input: %HTMLOutput $PluginMode $Expires $Lang $StyleS +heet $HTMLHeadSection $PageCode $PageDir + # Output: $HeaderHTMLSent=1 + + # Return: None + + #--------------------------------------------------------------------- +--------- + sub html_head { my $dir=$PageDir?'right':'left'; if (scalar keys %HTMLOutput || $PluginMode) { my $MetaRobot=0; # meta robots + + my $periodtitle=" ($YearRequired".($MonthRequired ne 'all'?"-$Mont +hRequired":"").")"; # Write head section + + if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') +{ if ($PageCode) { print "<?xml version=\"1.0\" encoding=\"$PageCode\"?>\n"; } else { print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; } ; if ($FrameName ne 'index') { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//E +N\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; } else { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset/ +/EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n"; } print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$ +Lang\">\n"; } else { if ($FrameName ne 'index') { print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitio +nal//EN\">\n\n"; } else { print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset/ +/EN\">\n\n"; } print "<html lang='$Lang'".($PageDir?" dir='rtl'":"").">\n"; } print "<head>\n"; print "<meta name=\"generator\" content=\"AWStats $VERSION from co +nfig file awstats.$SiteConfig.conf (http://awstats.sourceforge.net)\" + />\n"; if ($MetaRobot) { print "<meta name=\"robots\" content=\"".($FrameName eq 'mainlef +t'?'no':'')."index,nofollow\" />\n"; } else { print "<meta name=\"robots\" content=\"noindex,nofollow\" />\n"; }
and so on for more than 10,000 lines - in one file.

Note the way arguments are passed to a function: in global variables, and the neat way of printing just one line per print statement (OK: in all fairness later the author has discovered here-docs, but he has not refactored).
And of course it is a CGI program, but does not use CGI;.

I was trying to find a web-log-analyser tool with nice pictures for the PHBs, and google pointed me towards a site on sourceforge, where a well-documented tool was available in perl, with all the nice graphs management likes.

I recoiled in horror on looking inside the code and discovering a true treasure-trove for the perlmonks Pearls (or not) - a sample of which I just had to share.
I will now go on my way and find something better or (yuck) do it myself. Pity - it did look promising, and I am lazy and impatient.

All names withheld to protect the unnamed author.


In reply to Horrors abound by htoug
in thread Pearls (not really) of Perl programming by PetaMem

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (16)
    As of 2014-09-16 14:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (31 votes), past polls