Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

It might be faster and more accurate if $count was derived from keys %sites instead of incrementing it. This is especially true if some $siteid is not unique.

$count=0; $sth->bind_columns(\($siteid, $imageurl)); while($sth->fetch()) { $sites{$siteid}=$imageurl; $count++; }
Would become:
$sth->bind_columns(\($siteid, $imageurl)); while($sth->fetch()) { $sites{$siteid} = $imageurl; } $count = keys %sites;

$flag, $type, and $size don't have to be file scoped. If you reverse the logic of $flag and change its name to $error, the foreach block becomes easier to read.

my $error = 1; if ( my($type, $size) = ( head($imageurl) )[0, 1] ) { if ($size < 25600) { if($type =~ /image\/(gif|jpeg)/) { print "OK ($size bytes, $type)\n"; $error = 0; } else { print "Wrong file type ($type, must be image/gif or image/ +jpeg)\n"; } } else { print "Image size exceeded ($size bytes, should be < 25600)\n" +; } } else { print "Error\n"; } if ( $error ) { print FILE "update big_ass_table set imagedown=imagedown+1 where s +iteid=$siteid and imageurl='$imageurl';\n"; } else { print FILE "update big_ass_table set imagedown=0 where siteid=$sit +eid and imageurl='$imageurl';\n"; }



HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
254 968-8328

In reply to Re: URLs' Checking (Search Engines) by CharlesClarkson
in thread URLs' Checking (Search Engines) by nikos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found