I am a novice Perl programmer and need to change a perl script that I use to create web pages with thumbnail images and some text. Currently the script created a web page for each artist / category with all the thumb images below one another in the table. Thus the table has one column with a row for each image.
I am trying to change the script to have 3 columns in the table in the end (first testing with second column as in the attached script). The first row is filled with thumb images and text before the second row is filled etc.
I just cannot get the script to create the second column with the images etc.
I will really appreciate any help on this matter. If this problem is not suitable for the forum I appologise but will really appreciate it if a Perl programmer can contact me in this regard.
The script follows: -
# Stystem to build thumbnail image pages from data file
-
# (Use htmlkop and htmlstert files for the start and end of each html file)
-
-
#Set the Parameters
-
-
$meesterdir = 'C:\F\Websites\Johan Smith NEW\artwork\thumbshtml'; #Directory where HTML is written to
-
$datatabel = 'C:\F\Websites\Johan Smith NEW\artwork\datafile\datafile.txt'; #Directory were data file is
-
$tumbsdir = 'C:\F\Websites\Johan Smith NEW\artwork\htmlcategory'; #Directory were thumbs page that is being created will be saved
-
# print "$meesterdir\n";
-
-
#
-
-
#$htmlkop is the top part of HTML page
-
-
$htmlkopleer = 'C:\F\Websites\Johan Smith NEW\artwork\htmlkopthumbsnew.txt'; # File where htmlkop of the thumbs page is
-
#sleep(1);
-
# HTML kop
-
$fx ='';
-
open (LEER, $htmlkopleer) || the "Cannot open $htmlkopleer \n";
-
while (<LEER>) {$fx .=$_};
-
close (LEER);
-
-
#print $fx;
-
$htmlkop = $fx;
-
#print "$htmlkop\n";
-
sleep(1);
-
-
$htmlstertleer='C:\F\Websites\Johan Smith NEW\artwork\htmlstertthumbs.txt'; # File where htmlstert of the thumbs page is
-
-
# HTML stert
-
$fx ='';
-
-
open (LEER, $htmlstertleer) || the "Cannot open $htmlstert \n";
-
while (<LEER>) {$fx .=$_};
-
close (LEER);
-
-
#print $fx;
-
$htmlstert = $fx;
-
#print "$htmlstert\n";
-
sleep(1);
-
-
-
#
-
# Now the data file is read to go further
-
-
#Each category is for a different artist for which we want to build a html page with all the thumnails and info of his works
-
-
%category = (
-
'adriaanboshoff' => 'Adriaan Boshoff',
-
'alanainslie' => 'Alan Ainslie',
-
'johansmith' => 'Johan Smith',
-
); # end of list
-
-
#print $category; #Show category on screen to show what was done, this is just for testing the script.
-
sleep(1);
-
-
#foreach $katelem (keys(%category)) {print "test $katelem $category{$katelem}\n";sleep(5)}
-
-
foreach $katelem (keys(%category)) {
-
-
$catleernaam = $katelem;
-
-
# print "$catleernaam\n"; #Show catleernaam on screen to indicate that step was done - only for testing
-
# sleep(1);
-
-
-
sleep(1);
-
-
#$category='';
-
$subcategory= '';
-
-
-
-
-
$thumbleer = $tumbsdir.'\\'.$catleernaam.'.html';
-
print "$thumbleer thumbleer\n\n";
-
-
open (THUMBS,">$thumbleer") || die "kan nie thumb oopmaak nie
-
$thumbleer\n";
-
-
# Change <%cat_title%> with name of artist
-
#print "$katelem $category{$katelem} wie\n";
-
-
$htmlkopb = $htmlkop;
-
$htmlkopb =~ s/<%cat_title%>/$category{$katelem}/;
-
-
print THUMBS $htmlkopb;
-
-
-
# =========================================================
-
# From here the data line is read from data file and a test is done to see if it is still the same artist.
-
# =========================================================
-
open (LEER2, $datatabel) || the "cannot open data table
-
$datatabel oopmaak nie\n";
-
while (<LEER2>){
-
$ding3=$_;
-
-
chop($ding3); # Abstract one record line uit data table (file datafile.txt)
-
@velde = split(/%|%/,$ding3); # Split fields of each record at each %|%
-
-
if ($velde[24] eq $katelem) {
-
-
-
# Start of cell 1 contents ========================
-
print THUMBS "<tr><td align=center><font size=1><a href=\"../htmldetail/$velde[0]/index.html\"\><img
-
src=\"../htmldetail/$velde[0]/$velde[0]thumb.jpg\" align=center
-
alt=\"Click for more\"></a></font><br><font color=#ffffff align=center><span style=\"font-size: 8pt;\">$velde[12]</strong><br><br>
-
</font>
-
</span>
-
</td>"; #Cell 1 end
-
print THUMBS "";
-
sleep(1);
-
-
# -----------------------------------------------------------------------------------------
-
# Cell 2 in the same row
-
-
open (LEER2, $datatabel) || the "cannot open data table $datatabel \n";
-
while (<LEER2>) {
-
$ding3=$_;
-
-
chop($ding3); # Abstract one record line uit data table (file datafile.txt)
-
@velde = split(/%|%/,$ding3); # Split fields of each record at each %|%
-
-
if ($velde[24] eq $katelem) {
-
-
-
# Start cell 2 contents ========================
-
print THUMBS "<tr><td align=center><font size=1><a href=\"../htmldetail/$velde[0]/index.html\"\><img
-
src=\"../htmldetail/$velde[0]/$velde[0]thumb.jpg\" align=center
-
alt=\"Click for more\"></a></font><br><font color=#ffffff align=center><span style=\"font-size: 8pt;\">$velde[12]</strong><br><br>
-
</font>
-
</span>
-
</td>"; #Cell 2 end
-
print THUMBS "";
-
-
# --------------------------------------------------------------------------------------
-
-
-
-
} ;#end if;
-
}; # End while leer2
-
-
close (LEER2);
-
print THUMBS "$htmlstert";
-
close (thumbs);
-
} # End foreach $katelem
-
7 3364
Maybe the word "the" in some lines should be "die", for example: - open (LEER, $htmlkopleer) || the "Cannot open $htmlkopleer \n";
and there are several more lines like that. You can also add "$!" to die lines to get the specific error returned by the operating system: - open (LEER, $htmlkopleer) || die "Cannot open $htmlkopleer: $!\n";
Hi Mariusf
I've editted your post to enclose your script in a "CODE" tag, and also to add tabbed formatting. I noticed that your brackets are currently not balanced. Your missing closing brackets in at least 2 places, so I suggest that you go through your code and fix these things.
If you're still having problems after you do that, then repost your new code in a CODE tag, and we'll talk another look.
- Miller
Hi Mariusf
I've editted your post to enclose your script in a "CODE" tag, and also to add tabbed formatting. I noticed that your brackets are currently not balanced. Your missing closing brackets in at least 2 places, so I suggest that you go through your code and fix these things.
If you're still having problems after you do that, then repost your new code in a CODE tag, and we'll talk another look.
- Miller
Dear Miller
Thank you for your suggestions, I really appreciate your help.
I have closed the brackets as suggested and included the 3rd abstraction of the image and text for the 3 column table. What happens now is that if I test the scipt with 1 image from an artist, the same image and text is used 3 times in 3 columns in the same row. In other words, my loops are not working as they should. The loops for each of the 3 columns in the row should somehow test to see if there is another image and abstract the image and text from the data line.
I include the code below again: -
-
-
# Stystem to build thumbnail image pages from data file
-
# (Use htmlkop and htmlstert files for the start and end of each html file)
-
-
#Set the Parameters
-
-
$meesterdir = 'C:\F\Websites\Johan Smith NEW\artwork\thumbshtml'; #Directory where HTML is written to
-
$datatabel = 'C:\F\Websites\Johan Smith NEW\artwork\datafile\datafile.txt'; #Directory were data file is
-
$tumbsdir = 'C:\F\Websites\Johan Smith NEW\artwork\htmlcategory'; #Directory were thumbs page that is being created will be saved
-
# print "$meesterdir\n";
-
-
#
-
-
#$htmlkop is the top part of HTML page
-
-
$htmlkopleer = 'C:\F\Websites\Johan Smith NEW\artwork\htmlkopthumbsnew.txt'; # File where htmlkop of the thumbs page is
-
#sleep(1);
-
# HTML kop
-
$fx ='';
-
open (LEER, $htmlkopleer) || die "Cannot open $htmlkopleer: $!\n";
-
while (<LEER>) {$fx .=$_};
-
close (LEER);
-
-
#print $fx;
-
$htmlkop = $fx;
-
#print "$htmlkop\n";
-
sleep(1);
-
-
$htmlstertleer='C:\F\Websites\Johan Smith NEW\artwork\htmlstertthumbs.txt'; # File where htmlstert of the thumbs page is
-
-
# HTML stert
-
$fx ='';
-
-
open (LEER, $htmlstertleer) || die "Cannot open $htmlstert: $!\n";
-
while (<LEER>) {$fx .=$_};
-
close (LEER);
-
-
#print $fx;
-
$htmlstert = $fx;
-
#print "$htmlstert\n";
-
sleep(1);
-
-
-
#
-
# Now the data file is read to go further
-
-
#Each category is for a different artist for which we want to build a html page with all the thumnails and info of his works
-
-
%category = (
-
'adriaanhendrikboshoff' => 'Adriaan Hendrik Boshoff',
-
'johansmith' => 'Johan Smith',
-
'alanainslie' => 'Alan Ainslie',
-
); # end of list
-
-
#print $category; #Show category on screen to show what was done, this is just for testing the script.
-
sleep(1);
-
-
#foreach $katelem (keys(%category)) {print "test $katelem $category{$katelem}\n";sleep(5)}
-
-
foreach $katelem (keys(%category)) {
-
-
$catleernaam = $katelem;
-
-
# print "$catleernaam\n"; #Show catleernaam on screen to indicate that step was done - only for testing
-
# sleep(1);
-
-
-
# sleep(1);
-
-
#$category='';
-
$subcategory= '';
-
-
-
-
-
$thumbleer = $tumbsdir.'\\'.$catleernaam.'.html';
-
print "$thumbleer thumbleer\n\n";
-
-
open (THUMBS,">$thumbleer") || die "cannot open thumb $thumbleer: $!\n";
-
-
# Change <%cat_title%> with name of artist
-
#print "$katelem $category{$katelem} wie\n";
-
-
$htmlkopb = $htmlkop;
-
$htmlkopb =~ s/<%cat_title%>/$category{$katelem}/;
-
-
print THUMBS $htmlkopb;
-
-
-
# ==================================================
-
# From here the data line is read from data file and a test is done to see if it is still the same artist.
-
# ==================================================
-
open (LEER2, $datatabel) || die "cannot open data table $datatabel: $!\n";
-
while (<LEER2>){
-
$ding3=$_;
-
-
chop($ding3); # Abstract one record line uit data table (file datafile.txt)
-
@velde = split(/%|%/,$ding3); # Split fields of each record at each %|%
-
-
if ($velde[24] eq $katelem) {
-
-
-
# Start of cell 1 contents ========================
-
print THUMBS "<tr><td align=center><font size=1><a href=\"../htmldetail/$velde[0]/index.html\"\><img
-
src=\"../htmldetail/$velde[0]/$velde[0]thumb.jpg\" align=center
-
alt=\"Click for more\"></a></font><br><font color=#ffffff align=center><span style=\"font-size: 8pt;\">$velde[12]</strong><br><br>
-
</font>
-
</span>
-
</td>"; #Cell 1 end
-
print THUMBS "";
-
sleep(1);
-
} ;#end if;
-
}; # End while leer2
-
-
# -----------------------------------------------------------------
-
# Cell 2 in the same row
-
-
open (LEER2, $datatabel) || die "cannot open data table $datatabel: $!\n";
-
while (<LEER2>) {
-
$ding3=$_;
-
-
chop($ding3); # Abstract one record line from data table (file datafile.txt)
-
@velde = split(/%|%/,$ding3); # Split fields of each record at each %|%
-
-
if ($velde[24] eq $katelem) {
-
-
-
# Start cell 2 contents ========================
-
print THUMBS "<td align=center><font size=1><a href=\"../htmldetail/$velde[0]/index.html\"\><img
-
src=\"../htmldetail/$velde[0]/$velde[0]thumb.jpg\" align=center
-
alt=\"Click for more\"></a></font><br><font color=#ffffff align=center><span style=\"font-size: 8pt;\">$velde[12]</strong><br><br>
-
</font>
-
</span>
-
</td>"; #Cell 2 end
-
print THUMBS "";
-
-
} ;#end if;
-
}; # End while leer2
-
-
# -----------------------------------------------------------------
-
-
-
# Cell 3 in the same row
-
-
open (LEER2, $datatabel) || die "cannot open data table $datatabel: $!\n";
-
while (<LEER2>) {
-
$ding3=$_;
-
-
chop($ding3); # Abstract one record line from data table (file datafile.txt)
-
@velde = split(/%|%/,$ding3); # Split fields of each record at each %|%
-
-
if ($velde[24] eq $katelem) {
-
-
-
# Start cell 3 contents ========================
-
print THUMBS "<td align=center><font size=1><a href=\"../htmldetail/$velde[0]/index.html\"\><img
-
src=\"../htmldetail/$velde[0]/$velde[0]thumb.jpg\" align=center
-
alt=\"Click for more\"></a></font><br><font color=#ffffff align=center><span style=\"font-size: 8pt;\">$velde[12]</strong><br><br>
-
</font>
-
</span>
-
</td>"; #Cell 2 end
-
print THUMBS "";
-
-
} ;#end if;
-
}; # End while leer2
-
-
# -----------------------------------------------------------------
-
-
-
-
close (LEER2);
-
print THUMBS "$htmlstert";
-
close (thumbs);
-
} # End foreach $katelem
-
-
Maybe the word "the" in some lines should be "die", for example: - open (LEER, $htmlkopleer) || the "Cannot open $htmlkopleer \n";
and there are several more lines like that. You can also add "$!" to die lines to get the specific error returned by the operating system: - open (LEER, $htmlkopleer) || die "Cannot open $htmlkopleer: $!\n";
Thank you for the inputs, just to show you how a novice I really am: I have translated my comments in the script from my African language (Afrikaans) to English before the post. I did not recocnise that "die" is used in the perl scipt and thought that is should be "the" as translated from my language into English.
I have changed all that and include your recommended "$!" where required.
I have worked on the script and included it again in a message reply below.
Thanks so far.
Marius
another thing to note is you have this at the very end: - close (LEER2);
-
print THUMBS "$htmlstert";
-
close (thumbs);
it will not prevent your script from running but "thumbs" (lowercase letters) has to be "THUMBS" (uppercase letters) as it is a reference to the filehandle THUMBS.
As far as your problem goes it's hard to say, that is a lot of code to try and look through and to try and understand whats going on. The continually opening the same file over and over is probably part of the problem if not the whole problem. - open (LEER2, $datatabel) || die "cannot open data table $datatabel: $!\n";
-
while (<LEER2>) {
If you are going to print something into an html table you have to keep count of how many cells are getting printed (<td></td>) in order to know when to print a new row (</tr><tr>) and also to add empty table cells (<td></td>) to balance the rows and columns of the table. If all you ever intend is to print one row of three cells that should be easy. But if you have an unknown number or rows you have to keep track of when you come to the end of a row of cells.
another thing to note is you have this at the very end: - close (LEER2);
-
print THUMBS "$htmlstert";
-
close (thumbs);
it will not prevent your script from running but "thumbs" (lowercase letters) has to be "THUMBS" (uppercase letters) as it is a reference to the filehandle THUMBS.
As far as your problem goes it's hard to say, that is a lot of code to try and look through and to try and understand whats going on. The continually opening the same file over and over is probably part of the problem if not the whole problem. - open (LEER2, $datatabel) || die "cannot open data table $datatabel: $!\n";
-
while (<LEER2>) {
If you are going to print something into an html table you have to keep count of how many cells are getting printed (<td></td>) in order to know when to print a new row (</tr><tr>) and also to add empty table cells (<td></td>) to balance the rows and columns of the table. If all you ever intend is to print one row of three cells that should be easy. But if you have an unknown number or rows you have to keep track of when you come to the end of a row of cells.
Thanks for the inputs. I realise that I am out of my depth here. Is there anybody that can help me finalising the script for payment?
Alternatively I need to look at some free photo gallery type of scripts at http://gallery.menalto.com/ or http://coppermine-gallery.net/
Does some one have any suggestions?
I have no specific suggestion but I think it is a good idea you go with a pre-written image gallery script, there are tons and tons of them available. Which to use depends on your requirements. Copper-mine looks good.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Henk Verhoeven |
last post by:
(Reply on this newsgroup to an email - reply by email did not work)
Wolfman wrote:
>
> Hi,
> I found your Email in the php Newsgroup.
> I was looking for some way to resize some graphiks on my...
|
by: Don |
last post by:
I want the server-side php script to return a browser page that is essentially a copy of the
original client page that contained the <form> which referenced the php script in the first place....
|
by: Johan |
last post by:
Hi,
Where to find a php script to upload jpg files and make thumbnails of the
jpg files ?
Johan
|
by: Blue® |
last post by:
I would like to call the content of content.htm (containing only HTML
codes) into index.htm.
This is usually done by renaming index.htm to index.shtml and use this tag:
<!--#include...
|
by: mikeoley |
last post by:
Why would this script below work on an html page:
http://www.eg-designdev.com/aircylinders/test.htm
But not a java page such as this:
"http://www.eg-designdev.com/aircylinders/index3.jsp"
Or...
|
by: Penguiniator |
last post by:
I have a script that writes the body tag and adds a background
image to its containing page. This page is displayed in an
iframe inside a td tag of a table constructed with javascript.
The table...
|
by: Muzzy |
last post by:
Hi,
I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
|
by: ranger7419 |
last post by:
I'm trying to figure out why this script will work in IE 6 but not
Firefox, and so I need someone here with a far better grasp on
javascript to explain this. Basically, I have a page with several...
|
by: Angus |
last post by:
I have a web page with a toolbar containing a Save button. The Save
button can change contextually to be a Search button in some cases.
Hence the button name searchsavechanges.
The snippet of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |