Assuming that the format for every grade is ' <b>NAME</b>, grade: GRADE<br>' and that there are no lines that begin incidentally with the same format (Well actually you don't have if you use the regex I wrote. At least I think so...), you can use this little snippet that uses regex to create this HTML page (You can easily alter it as you wish to just print it and not create an HTML file):
open (FILE, "+<$path/finalgrades.html") or die "Can't open file: $!";
+# where $path is the full path to the directory where the file reside
+s.
while (<FILE>) {
if (m/^<b>[^<>]</b>, grade: (\d+)<br>$/) {
my $name = $1; my $grade = $2;
open (HTML, "+>>$path/$name.html") or die "$!";
print HTML "<html><head><title>CONGRATULATIONS TO THE PARTICIPANT
+$name</title></head><body><h1>$name</h1> has just reviece "$grade" as
+ a grade for this seminar. Congratulations!!!<br></body></html>
}
}
close (FILE) or die "$!";
Note that you should want to use CGI.pm to print the HTML taks instead of printing them directly. Go to http://search.cpan.org/author/LDS/CGI.pm-2.93/CGI.pm for more info on the CGI module.
--------------------------
Live fat, die young
-
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.
|