Google Groups Home
Help | Sign in
Message from discussion Need ideas on how to make this code faster than a speeding turtle
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
cha...@lonemerchant.com  
View profile
 More options May 15, 5:32 pm
Newsgroups: comp.lang.perl.misc
From: cha...@lonemerchant.com
Date: Thu, 15 May 2008 14:32:50 -0700 (PDT)
Local: Thurs, May 15 2008 5:32 pm
Subject: Re: Need ideas on how to make this code faster than a speeding turtle
On May 15, 2:21 pm, cha...@lonemerchant.com wrote:

> On May 15, 1:37 pm, Uri Guttman <u...@stemsystems.com> wrote:

> > >>>>> "c" == chadda  <cha...@lonemerchant.com> writes:

> > i have to know if you could write this mess any slower? you are doing
> > everything possible to slow you down.

> I know I shouldn't critize free help, but you seem to have some anger
> management issues.

> >   c> open(IN, '<', 'input') || die "cant open: $!";
> >   c> $read = <IN>;
> >   c> chomp($read);
> >   c> $build = "http://www.doba.com/members/catalog/".$read.".html";
> >   c> $temp = `lynx -accept_all_cookies -dump $build`;

> > why are you calling out to a program when perl can load web pages just
> > fine with LWP? did you even look for web stuff on cpan?

> Would using LWP speed up the code? By the way, this code is meant to
> run on a server with restricted access. Ie, I can't install stuff from
> cpan on that server.

> >   c> open(OUTFILE, '>out');
> >   c> print OUTFILE $temp;
> >   c> close OUTFILE;

> >   c> open(OUT, '<', 'out') || die "cant open: $!";
> >   c> @shit = <OUT>;

> > why are you writing out the output of lynx JUST TO READ IT BACK IN
> > AGAIN? this is the most absurd part of this program.

> > you have the text in $temp. you know how to use backticks but why do you
> > do the file write and reading back in? if you assigned the backticks to
> > an array you would get the same thing as in @shit without the wasted
> > effort.

> > also calling it @shit is not a good thing.

> Huh? Are you saying I don't need the 'out' file?

Maybe something like this?
% more parse.pl
#!/usr/bin/perl -w

my (@shit, $read, $build, @product, @id, @sku, @upc, @weight);
my @temp;

open(IN, '<', 'input') || die "cant open: $!";
$read = <IN>;
chomp($read);
$build = "http://www.doba.com/members/catalog/".$read.".html";
@temp = `lynx -accept_all_cookies -dump $build`;

@product = grep(/Product ID/, @temp);
@id = grep(/Item ID/, @temp);
@sku = grep(/SKU/, @temp);
@upc = grep(/UPC/, @temp);
@weight = grep(/Weight/, @temp);

print @product;
print @id;
print @sku;
print @upc;
print @weight;

However, I don't know how to use LWP. Again, would the code run faster
if I used LWP?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google