Home: Perl Programming Help: Regular Expressions:
problem sorting lynx result



danielpcorrea
Novice

May 12, 2009, 9:17 AM


Views: 9179
problem sorting lynx result

Hi guys
Im taking html data using lynx text-based web browser. Anybody can help me?

Im receiving a strange error:


Code
sh: Syntax error: Unterminated quoted string 
Non apre csv. at ./chk_calk.pl line 41, <TEMP1> line 24.



Code
    my $callynx="/usr/bin/lynx -source $grafico_link|"; 
print $callynx,"\n";
open (TEMP1, $callynx);# or die "non chiama lynx...";

while (<TEMP1> ) {

if ($_ =~ m/csv/) {

$csvtmp= substr($_,38,$numcarac);
$urltmp="http://10.212.143.52/immagini/" . $csvtmp;
$wgetexec="wget " . $urltmp; #prepara download .csv
$system=system($wgetexec); #fa il download
$csvtmp=$base_add . "/" . $csvtmp;

open (TEMP2, $csvtmp) or die "Non apre csv.";

while (<TEMP2> ) {
print $_;
}
close (TEMP2);
}
}
close(TEMP1);



KevinR
Veteran


May 12, 2009, 10:11 AM


Views: 9176
Re: [danielpcorrea] problem sorting lynx result

The error appears to be coming from the shell, not perl. There are no syntax errors in the perl code you posted although it appears to be only a part of a larger perl script, so there could be an error somewhere else in the perl code.
-------------------------------------------------


alex_v2
User

May 12, 2009, 10:18 AM


Views: 9174
Re: [KevinR] problem sorting lynx result

Yeah I am with Kevin on this one. It is saying line 41 of the script is having issues. If you could highlight which line you posted is line 41 and then also give us the 24th line of the file (or the first 50 lines even) that would be great.

-Alexander


(This post was edited by alex_v2 on May 12, 2009, 10:19 AM)


danielpcorrea
Novice

May 13, 2009, 12:21 AM


Views: 9163
Re: [danielpcorrea] problem sorting lynx result

Hi guys

I think the problem is the method OPEN, because this code works fine in another cases. Im opening html codes, and probably this page has something that Open method isnt recognizing.

Thsnks for your reply
Daniel


alex_v2
User

May 13, 2009, 7:36 AM


Views: 9154
Re: [danielpcorrea] problem sorting lynx result

Open itself does not try to interpret anything though I have to say I have never used open to for a file handle and trap content from a browser.

My main experience with thing like this I actually use LWP or LWP::Simple depending on my needs. Looking around the net I have seen you post a few things on a few forums. Are you tied to using lynx for a reason? Have you looked into LWP and LWP::Simple and they don't suit your needs?

-Alexander


danielpcorrea
Novice

May 13, 2009, 8:42 AM


Views: 9150
Re: [alex_v2] problem sorting lynx result

Hi Alex and guys

I've resolved the problem with a little different solution. Now it's working fine.


Code
    my $callynx="/usr/bin/lynx -source $grafico_link|"; 
open TEMP1, $callynx or die "non chiama lynx...";

$_ = "";
$_ = <TEMP1> until /\.csv/;
$csvtmp = $_;