[ic] eBay UserTags Update

Grant emailgrant123b at yahoo.com
Tue Mar 23 12:18:35 EST 2004


--- Kevin Walsh <kevin at cursor.biz> wrote:
> Grant [emailgrant123b at yahoo.com] wrote:
> > I posted 4 eBay UserTags a little while back and
> this
> > change affects all of them.  If anyone is using
> any of
> > those tags, change the following line:
> > 
> > if ($response) {
> > 
> > to this:
> > 
> > if ($response =~ /^<\?xml/ ) {
> > 
> > That should prevent a non-XML response from
> crashing XML::Simple.
> > 
> I just had a look at one of your old articles (14
> November 2003) and
> your UserTag is doing this:
> 
>     my $response = $request->content();
> 
> Perhaps it would be a good idea to do something
> similar to this first:
> 
>     die 'Goodbye cruel world' unless
> $request->is_success();
> 
> You don't have to "die", of course, but doing some
> error checks should
> help you to avoid non-XML responses.  See
> LWP::UserAgent for more
> information on how to show the specific error
> messages etc.

That sounds like a really good idea for a more
complete/correct tag.  My Perl-writing speed probably
averages 1 character per minute though, so I better
not get into it.

I did get some more info from the Perl group I got the
modified code from.  Apparently "Regexes are not the
Right Tool for constant strings" so I'm replacing:

if ($response =~ /^<\?xml/ ) {

with:

if ( index($response, '<?xml') == 0 ) {

in all the tags.  I'll be sure to let everyone know if
this causes problems.

- Grant

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html


More information about the interchange-users mailing list