in reply to Re: Unexpected output from my PERL program. WHAT is my problem???
in thread Unexpected output from my PERL program. WHAT is my problem???

Then the server returned no content in its response.

Then how come if I call the Perl script by itself (on the command line and NOT from my C program), it prints "HELLO-Hello-HELLO" with no blank to stdout?

So the only problem is that you want to extract some data from the file you are downloading. For starters, we need to know in what format is the file you are downloading, and in what encoding do you want the extracted data to be.

I set the content-type explicitly in the webserver to return content as "text/plain". I am just trying to print out simple text and nothing else. I want the format to be latin1/iso-8859-1. I want to get the same behavior as if I simply issued a "print $var" command as in the original posting example. I'm getting two different behaviors that I don't think i should expect to get.
  • Comment on Re^2: Unexpected output from my PERL program. WHAT is my problem???

Replies are listed 'Best First'.
Re^3: Unexpected output from my PERL program. WHAT is my problem???
by ikegami (Patriarch) on Nov 04, 2009 at 16:26 UTC

    Then how come if I call the Perl script by itself, it prints "HELLO-Hello-HELLO" with no blank to stdout?

    I've already updated my earlier post with an answer to that. ("You're going to insist ...")

    I am just trying to print out simple text and nothing else. I want the format to be latin1/iso-8859-1

    binmode(STDOUT, ':encoding(iso-8859-1)'); print $response->decode_content(default_charset => 'UTF-16be');
      ikegami: Thanks for all your help. That was all that I needed....those TWO LINES:

      binmode(STDOUT, ':encoding(iso-8859-1)'); print $response->decode_content(default_charset => 'UTF-16be');


      I don't know how I missed that the first time you posted it.

        Two things I meant to say:

        Since the perl program now returns text according to your C program's definition, you won't have problems with popen

        iso-8859-1 can only represent a small subset of the characters supported by UTF-16. The conversion to iso-8559-1 may result in information loss.

        I don't know how I missed that the first time you posted it.

        This is the first time I posted this. I needed to know what kind of data you had before I could post a solution. The solution is not a general solution. It would be inappropriate for XML, for example.

        Two things I meant to say:

        Since the perl program now returns text according to your C program's definition, you won't have problems with popen

        iso-8859-1 can only represent a small subset of the characters supported by UTF-16. The conversion to iso-8559-1 may result in information loss.

        I don't know how I missed that the first time you posted it.

        This is the first time I posted this. I needed to know what kind of data you had before I could post a solution. The solution is not a general solution. It would be inappropriate for XML, for example.