If your output to the text file is clean, chances are the line breaks are just HTML preferentially breaking a line (first on the [], then on the -) because it considers the line too long for a single line of screen output.
I've never worked with GD but I assume Invalid data set: 0 means it doesn't like the int 0, that could mean anything - it's possible it's looking for a float instead of an int? All your other numebrs are floats... No idea. Anyway, the line breaks won't be a problem with PERL, just a display "feature" with HTML. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hsu, David Sent: April 13, 2005 1:49 PM To: [EMAIL PROTECTED] Cc: [email protected] Subject: RE: String formatting Thanks all for the suggestions, I tried $data =~ s/\r//g; and also with \n. Still the same output. I outputted the string to a text file, and it is all in one line. So, I'm still baffled to why it is printing in separate lines in HTML format and the "invalid data set" error when I try to graph. David ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 12, 2005 5:20 PM To: Hsu, David Cc: [email protected] Subject: Re: String formatting In a message dated 4/12/2005 3:56:43 P.M. Eastern Standard Time, [EMAIL PROTECTED] writes: > Hi all, > > I am working with GD::Graph and I am retrieving some data from a DB and > formatting the data into a string that I can use for graphing. > my @data = ($data1); > My $myGraph = GD::Graph::lines->new(400,300); > ... > > The problem is that my formatted string of data is not in the correct > format and returns an error. I check the string printed to the screen > and it looks like this: > > [-0.84,-0.83,-0.4,-0.39,- > 0.39,1.16,2.38,4.49,7.08,10.07,13.14], > [1.09,0.47,-14.95,-47.63,- > 5.75,30.19,21.07,37.63,57.18,84.63,118.59], > [0,0.06,-21.27,-59.79,- > 11.11,22.26,12.67,15.25,10.79,6.58,4.52,4.05] > Invalid data set: 0 at c:\inetpub\wwwroot\trialmap\cgi-bin\eData.pl line > 2106. > > >From my testing, the array needs the data to be either one line, or 3 > lines separated by the brackets. > I am assuming they are return carriages, (but I am not sure why it is > there) so I try this RE to remove it, with no luck. > $data1 =~/(\r)//g; this a match, but not a substitution. try ``$data =~ s/\r//g;'' (capturing parentheses are not needed). also, the line break may a newline rather than a carriage return: try \n in place of \r. > > Any insights? > Thanks > David _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
