Monday, April 30, 2001

Apr 30 2001

Well, after looking around for a simple link verification program, I couldn’t find one that suited my needs. So, I wrote one. It’s a little Perl program that looks through a directory, takes every file it finds, and scans it for links. It then checks each link to see if it’s valid, and prints out messages based on what it finds. Pretty useful little thing.

However, it’s exhibiting a very annoying bug. Maybe one of you can help me. Here’s the code snippet:

 $found = 0;
$linecount = 0;while( $linecount < 10 ){$line = <$sock>;if( $line ne '' ){$linecount++;chop( $line );if( index( $line, '404' ) >= 0 ){ $found = 1; $linecount = 1000; }elsif( $linecount == 1 && index( $line, ' 302 ' ) >= 0 ){# Redirection!$found = 2;$linecount = 1000;}} # end if line exists} # end loop

This code is executed after sucessfully connecting to a particular server, and sending it a request for a page. Nothing is sent back from the server. The problem is that the program hangs on that $line = <$sock>; line (which requests a line of data from a server), and I have no idea how to make that particular line of code time-out. Any ideas?

In other news…I worked 12 hours at work today, meaning I didn’t get home until 9:00 p.m. After a really good talk with my Mom about some issues we’re dealing with, I answered e-mails and collapsed into bed. Highly unproductive.

No responses yet

Leave a Reply

I work for Amazon. The content on this site is my own and doesn’t necessarily represent Amazon’s position.