Re: [SLUG] Fun with perl

From: Aharon (aharon@superfreeway.com)
Date: Fri Mar 22 2002 - 15:12:37 EST


open (log,"/var/www/html/auth.log");
while (<log>) {
        if ($_ =~ /joeuser/) {
                print "$_<BR>\n";
        }
}
close (log)

The reason it's jumbled is becuase you need to add <BR>'s to the end of
each line.

Or you could simply add <PRE> before your print and </PRE> after your
print.

Example:
#!/usr/bin/perl
print "Content-Type: text/html \n\n";
print "<PRE>\n";
print `cat -b /var/www/html/auth.log | grep joeuser`;
print "</PRE>\n";

Aharon

On Fri, 22 Mar 2002, Brett Simpson wrote:

> I'm looking to use this script in my apache cgi-bin so that users can list specific contents of a file in their web browser. It works ok except that it jumbles the lines togethor. Is there a cleaner way to do this so that it looks readable?
>
> #!/usr/bin/perl
> print "Content-Type: text/html \n\n";
>
> print `cat -b /var/www/html/auth.log | grep joeuser`;
>
>
> Brett
>

-- 
Sr Unix Administrator
Tampa, Florida

Websites: http://www.tamparacing.com http://www.tampaforums.com http://www.ls6.com http://www.lastgen.com http://www.xmbforum.com



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:28:40 EDT