Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Stupid Program!

by CharlesClarkson (Curate)
on Dec 01, 2001 at 04:47 UTC ( #128805=note: print w/ replies, xml ) Need Help??


in reply to Program can't work on website; please examine code

There's rarely a good reason for mixing CGI.pm routines with actual HTML. You are also using poorly formed HTML. By making a few assumptions, I was able to get this. It's easier to read and maintain without the HTML. It's also easier to write it this way.

#!/usr/bin/perl use strict; use diagnostics; use CGI; # create a new CGI object my $page = new CGI; # used during testing # $page->param('Comic', 'Images/Le_Comic6.jpg'); # Grab a named CGI parameter my $comic = $page->param('Comic'); exit unless $comic; my $menu = $page->div({-class => 'Standard' }, $page->p( $page->cente +r( $page->a({-href => '../index.htm' }, '[Home]' ), $ +page->hr, $page->a({-href => '../Gallery.shtml' }, '[Gallery]' ), $ +page->hr, $page->a({-href => '../Manga.shtml' }, '[Manga]' ), $ +page->hr, $page->a({-href => '../Video_Review.shtml'}, '[Video Reviews]'), $ +page->hr, $page->a({-href => '../Links.shtml' }, '[Links]' ), $ +page->hr, $page->a({-href => '../Web_Comic.shtml' }, '[Web Comic]' ), $ +page->hr ))); my ($comment, $number, $comic_links); { my @file_names = qw| Images/Le_Comic.jpg Images/Le_Comic2.jpg Images/Le_Comi +c3.jpg Images/Le_Comic4.jpg Images/Le_Comic5.jpg Images/Le_Comi +c6.jpg Images/Le_Comic7.jpg Images/Le_Comic8.jpg Images/Le_Comi +c9.jpg Images/Le_Comic10.jpg Images/Le_Comic11.jpg Images/Le_Comi +c12.jpg Images/Thanksgiving_Comic.jpg |; # Open up the comments file open my $fh, '../Comment.txt' or die $!; my ($i, @links); foreach my $file_name ( @file_names ) { chomp( my $line = <$fh> ); ($comment, $number) = ($line, $i) if $file_name eq $comic; push @links, $page->a({-href=>"Testy.cgi?Comic=$file_name" +}, 'Comic #', ++$ +i); } $links[11] = $page->a({-href=>"Testy.cgi?Comic=$file_names[12] +"}, 'Thanksgiving Comi +c' ); $comic_links = $page->p( $page->b( $page->u('Comics') ) ) . $page->p( (join ' | ', @links[0 .. 4]), $page->br, (join ' | ', @links[5 .. 9]), $page->br, $links[10] ) . $page->p( $page->center( $page->u( $page->font( { -face => 'Comic Sans MS', -size => 4}) +)), $page->br, $links[11] ); } print $page->header, $page->start_html( -head => $page->Link({ -rel => 'stylesheet', -href => '../Style.css', -type => 'text/css'} ), -title => "Animetion Station > Webcomic > Comic #$number", -meta => { GENERATOR => 'Adobe PageMill 3.0 Win' } ); print # Web Comics $page->p( $page->center( $page->div( { -style => q| background-color: #0099FF; font-family: Comic Sans MS; font-size: 20px; width: 200px; color: white;| }, 'Web Comics' ))); print # Table $page->table( { -width => 757, -border => 0, -cellspacing => 1, -cellpadding => 0, -height => 294 }, $page->Tr( $page->td( { -width => '14%', -valign => 'TOP', -align => 'CENTER', -height => 293 }, $menu ), $page->td( { -width => '86%', -valign => 'TOP', -bgcolor => '#3366ff' }, $page->p( $page->center( $page->img( {-src => '../$value'} ) ) ), $page->br, $page->p($comment), $page->center( $page->div({ -style => q| font-family: Times New Roman, Time +s; color: white; width: 350px; background-color: gray; text-align: center;| }, $comic_lin +ks ) ) ) ) ), $page->end_html; __END__



HTH,
Charles K. Clarkson

And he puzzled three hours, till his puzzler was sore.
Then the Grinch thought of something he hadn't before!
- Dr. Seuss


Comment on Re: Stupid Program!
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://128805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-04 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls