From owner-freebsd-ports@FreeBSD.ORG Sun Sep 4 23:58:01 2005 Return-Path: X-Original-To: freebsd-ports@freebsd.org Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EBB0016A41F for ; Sun, 4 Sep 2005 23:58:01 +0000 (GMT) (envelope-from parv@pair.com) Received: from mta9.adelphia.net (mta9.adelphia.net [68.168.78.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F6EE43D46 for ; Sun, 4 Sep 2005 23:58:01 +0000 (GMT) (envelope-from parv@pair.com) Received: from default.chvlva.adelphia.net ([69.160.76.67]) by mta9.adelphia.net (InterMail vM.6.01.04.01 201-2131-118-101-20041129) with ESMTP id <20050904235758.YHVU24716.mta9.adelphia.net@default.chvlva.adelphia.net>; Sun, 4 Sep 2005 19:57:58 -0400 Received: by default.chvlva.adelphia.net (Postfix, from userid 1000) id 81E61B541; Sun, 4 Sep 2005 19:57:59 -0400 (EDT) Date: Sun, 4 Sep 2005 19:57:59 -0400 From: Parv To: Charles Maner Message-ID: <20050904235759.GA19238@holestein.holy.cow> Mail-Followup-To: Charles Maner , freebsd-ports@freebsd.org References: <20050904213928.GA17782@holestein.holy.cow> <20050904230401.9653.qmail@web54501.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050904230401.9653.qmail@web54501.mail.yahoo.com> Cc: freebsd-ports@freebsd.org Subject: Re: Perl libwww--LWP::Simple X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Sep 2005 23:58:02 -0000 in message <20050904230401.9653.qmail@web54501.mail.yahoo.com>, wrote Charles Maner thusly... > Could you please not post your reply before the quoted text? > Hi Parv--thanks for the reply. My code, on all three > platforms, is: > > ##### Begin Code ########## > use strict 'vars'; > use strict 'subs'; > > use LWP::Simple; > > LWP::Simple::getstore("http://biz.yahoo.com/i/","tickers.html") > or die("Website not found!\n"); > > open TICKERS, "tickers.html"; You should check the return value of open(), else you will get bogus error from close() if the file does not exist. > my @tickers = ; > > print "@tickers\n"; > > close TICKERS; > > exit; > ##### End Code ########## When i run the above code i get the page intended for a robot; below are the first few lines ... Yahoo! Finance Company and Fund Index

... working alright. Given (from LWP::Simple pod) ... getstore($url, $file) Gets a document identified by a URL and stores it in the file. The return value is the HTTP response code. ... you need to check the HTTP return code from getstore() which is DIFFERENT from perl return values. Say, if getstore() returns 404, above code will continue to work past the close() (if tickers.html already exists) till the exit(). I say, just use the LWP::UserAgent module and get better/easier/more control. - Parv --