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
Uri Guttman  
View profile
 More options May 15, 5:47 pm
Newsgroups: comp.lang.perl.misc
From: Uri Guttman <u...@stemsystems.com>
Date: Thu, 15 May 2008 21:47:04 GMT
Local: Thurs, May 15 2008 5:47 pm
Subject: Re: Need ideas on how to make this code faster than a speeding turtle

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

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

yes.

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

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

  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`;

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

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

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

better but forking off lynx is still slow. LWP should be much faster. if
you want speed (and with the data size you have, you want it), use LWP.

depending on how fast you need it (cpu usage will spike with the greps
you have) you can also change all that to parse out what you want with
regexes. (again, that assumes a known fixed html page layout which you
seem to have).

uri

--
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


    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