My guess is that you have "\r" somewhere in your incoming lines, but you
need to find out what is really there.  Once you know that, you can use
s///g to remove it.

I'd probably run the script under the debugger so I can see exactly what is
in $line at any point.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
----- Original Message -----
From: "Fran�ois Nadeau" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 22, 2001 08:57
Subject: Problem: LWP unwanted line break


> I have a LWP problem causing a JavaScript Unterminated String Constant
> error.
>
> The goal is to put some stock quote information in a JavaScript array for
> use in a web page.
>
> The problem is that a line break gets inserted in the stocktext[1]
variable
> (through $line).
>
> Can someone help me get rid of the unwanted line break?
>
>
> Here's the code:
>
> #---Begin code---------------------------------------
> #!/usr/local/bin/perl
>
> select(stdout);
> $| = 1;
> print "Content-type: text/html\n\n";
> use LWP::UserAgent;
> $Web_agent = new LWP::UserAgent;
> my $req = new HTTP::Request GET =>
> 'http://quote.canada-stockwatch.com/sw/custom/textq.cfm?pw=cms44tuv91';
> my $res = $Web_agent->request($req);
> my @lines_ouput = ();
> my $line;
>
> if ($res->is_success)
>
> {
> @lines_ouput = split(/\n/,$res->content);
>
> print "<script language='JavaScript' type='text/javascript'> \n";
> print "var stocktext = new Array(3); \n";
>
> foreach $line (@lines_ouput)
>
> {
>
> if ($line =~ /chartf\.stockwatch\.com\/c\/C/)
> {
> $firstText = 'stocktext[1] = "' . $line . '";';
> print $firstText;
> print "\n";
> }
>
> else
> {
> $newline = "";
> print $newline;
> }
> }
>
> print "</script> \n";
>
> }
> else
> {
> print "<H2>Houston, we have a problem</H2>\n";
> }
> exit(0);
>
> #--End code--------------------------------------------
>
> Best regards,
>
>
> Fran�ois Nadeau
> www.cloudraker.com
> T. 514.499.0005 ext:230
> F. 514.499.0525
>
>

Reply via email to