Sorry if I post in wrong place at first time at "cool use the perl". Anyway here, I am learning on Perl and I wrote the array so I am wondering if that's good or what? I just want to improvement my perl skill & knowledge. I am trying to make array to read from bottom to top in the database. The inside of database looks like this "Date|Title|URL|Comments", so here's array code. Any feedback on array?
This is example of database.
07.11.2001|Hello World1|www.domain1.com|Your Comments in Here
07.12.2001|Hello World2|www.domain2.com|Your Comments in Here
07.13.2001|Hello World3|www.domain3.com|Your Comments in Here
07.14.2001|Hello World4|www.domain4.com|Your Comments in Here
#This is array to read from bottom to top.
my @all_array;
open(FILE,"$datadir/$datafile") || &Errormsg("Please correct your path
+ or chmod of database.");
while (<FILE>) {
@_ = split /\|/;
my $hash_ref = {
DATE => $_[0],
TITLE => $_[1],
URL => $_[2],
COMMENTS => $_[3],
};
push @all_array, $hash_ref;
}
close(FILE);
foreach (reverse @all_array) {
print "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpa
+dding=\"3\">";
print " <tr>";
print " <td><font color=\"orange\"><b>$_->{'TITLE'}</b></font><
+br><font size=\"1\">Posted - $_->{'DATE'}</font></td>";
print " </tr>";
print " <tr>";
print " <td>$_->{'COMMENTS'} (<a href=\"$_->{'URL'}\" target=\"
+_blank\">more information</a>)</td>";
print " </tr>";
print "</table><br>";
}
Thanks,
Jeremy
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.