Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
that's close. The filehandle is a reference to the file, so instead of having the path to the file, it needs to be a keyword or decriptive word. Then inside the quotes you need to put the filename (with path).

Here's what it should look like:

#!/usr/bin/perl -w use strict; use CGI; # start new cgi process my $main=new CGI; # print html headers print $main->header; # print html tags and add title print $main->start_html ("Printer Status"); # open /usr/lsys/printstatus/printstatus.out under filehandle LOGFIL +E open(LOGFILE," /usr/lsys/printstatus/printstatus.out"); # while there is data in LOGFILE while(<LOGFILE>) { # remove newlines (\n) from input chomp; # if the imput is not the divider line if (! ($_=~/----------------------------/)) { # put the contents of the current line into the array @status # we are spliting on the space so that every word seperated by # a space becomes a new element in the array my @status = split(/ /, $_); # if the first element of @status does not equal 'name' (the t +itle header if (($status[0] eq "name") && ($status[1] eq "display")) { # print the start of the table print "<center><table width=250 border=1><tr align=center> +\n"; # for each element in @status for (@status) { # print a new table cell print "<td><b>$_</b></td>\n"; } # close the table row print "</tr>\n"; } } } # close the table print "</table>\n"; # close LOGFILE close (LOGFILE); exit;
if you are curious about some of the commands/functions that are used, type perlfunc:NameOfFunction in the super search.
-p

In reply to Re: Re: Re: Re: Re: Unix Perl and Html by thatguy
in thread Unix Perl and Html by meccaxlr

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-16 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found