-
Please get yourself a copy of The Pragmatic Programmer, and read and reread the section on DRY:
Don't Repeat Yourself.
The fetching part of the script should be rolled into a function that handles a given strip, and then called for each of the strips. What you're doing there is a maintenance nightmare.
- How is one to know what $i means? It's not in a loop, so I have no clue unless I look at it throughout the code.
- Your file opening test is meaningless because it can never succeed. || is not the same as or. What you're calling there as
open PAGE, ">comics.html" || die $!;
is effectively
open PAGE, (">comics.html" || die $!);
The part in parens will ALWAYS evaluate to ">comics.html". What you want is:
open PAGE, ">comics.html" or die $!;
which is effectively
(open PAGE, ">comics.html") or die $!;
- If you're using Perl 5.6.0+, avoid the bareword style filehandles, and instead use
open my $fh, ">", "comics.html" or die $!;
The rest of the comments posted are good ones, too.
xoxo,
Andy
--
<megaphone>
Throw down the gun and tiara and come out of the float!
</megaphone>
-
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.
|