Hi,

2010/9/4 ashar rizqi <asharri...@gmail.com>:
> Hi All
>
> I am trying to get to a webpage, look for matches of prices, print those
> matches to a file and send that file to excel where a chart is automatically
> generated. I dont have a problem with sending it to excel or getting to the
> webpage. I cant get it to match all the prices on the page and send all
> those matches to a file. I am using strawberry perl. I can do this in linux
> but linux doesnt have excel and theres nothing available to automate
> openoffice spreadsheet. Here is the closest I could get to it:
>

Actually you could use
http://search.cpan.org/dist/Spreadsheet-WriteExcel/
to create an Excel file on Linux as well
and I guess there are similar modules to generate
Open Office Calc documents.

Regarding your code. There is a bug that you are using $ witout
escaping it. This causes perl to think you are actually trying to use
the strange but valid $'

You could have find out about this bug if you were using

use strict;
use warnings;

at the beginning of your code as it would give you a warning:

Use of uninitialized value $' in regexp compilation at a.pl line 5.

that would have triggered your suspition.

I'd recommend that you start doing that.

You could use WWW::Mechanize but for a simple get request
I'd recommend using LWP::Simple and you don't need to save the
received content to a file, you can go over its lines while in memory;

use strict;
use warnings;

use LWP::Simple qw(get);
my $content = get( "http://austin.craigslist.org/apa/"; );
my @lines = split /\n/, $content;

open (my $OUT, ">", "list.txt") or die;
foreach my $line (@lines) {
   if  ($line =~ /'\$'[0-9].*/) {
     print $OUT $line;
  }
}

regards
   Gabor

-- 
Gabor Szabo
http://szabgab.com/
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to