Well, hold on there, friend -- no need to get punchy. You might have mentioned that you had this problem in your browser, and not in an editor: this is why it's important to be complete when asking a question, here.

To fix this code-side rather than client-side, you need to instruct your code to use Windows-style line endings. In your code, wherever you see "\n", use "\r\n" instead. If there are a great number of places that you've already used "\n" and you don't want to hunt them down, you could also use a short Perl script to convert them right before viewing. This might look like:

#!/usr/bin/perl use strict; use CGI::Simple; my $q = new CGI::Simple; $| = 1; print $q->header( -type => 'text/plain', -expires => '+1m' ); ## the header is for plain text, and the data expires in 1m ## If there's no file parameter, exit with an error message unless ($q->param('file')) { print 'No File was requested'; exit; } open LOG, '<', $q->param('file') or do { # exit with error if we can't open the file print 'Unable to open file ',$q->param('file'),':',$!; exit; }; while (<LOG>) { s{(\r\n)|(\n)}{\r\n}g; ## replace unix with Win line-endings print $_; }
This is untested

This should be invoked as http://www.domain.com/myname.pl?file=logs.txt (if you named your script 'myname.pl').


The Eightfold Path: 'use warnings;', 'use strict;', 'use diagnostics;', perltidy, CGI or CGI::Simple, try the CPAN first, big modules and small scripts, test first.


In reply to Re^3: log file formatting by radiantmatrix
in thread log file formatting by centrum

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.