in reply to Incomplete Output When Printing Hash

The story sounsd wierd, but try this snippet to get a hint on the output:

use Data::Dumper; print "<html><meta http-equiv='content-type' content='text/html; chars +et=UTF-8'><BR/><BR/>"; print "<BR/>FtchObjtDets<BR/><BR/>"; print "<pre>\n"; print Dumper(\%myobjtdets), "\n"; print "</pre>\n"; print "</html>"; exit;

And show us the output.

Update: I don't know, what you meant with "print". Is the only output to a browser via your snippet? You should look at the Dumper output on the console. What you don't do: You do not encode HTML entities. When the elements of your hash contain HTML special characters like "<", you're generating HTML tags.

McA

Replies are listed 'Best First'.
Re^2: Incomplete Output When Printing Hash
by FAX (Novice) on Aug 18, 2013 at 20:33 UTC

    Tested your code. Unfortunately, it appears to have a problem since, at form submission, I am prompted with a download option (typical when there's some syntax issue). I'll tinker with it a bit and try to find the problem. (Maybe I copy/pasted something wrong and broke a line).

    FAX

    Okay ... modified your code ... here's the version that worked on Firefox 12.0 ...

    use Data::Dumper; print "<html><meta http-equiv='content-type' content='text/html; chars +et=UTF-8'><BR/><BR/>"; print "<BR/>FtchObjtDets<BR/><BR/>"; print "<pre><BR/>"; print Dumper(\%myobjtdets); print "<BR/></pre><BR/>"; print "</html>"; exit;

    Interesting that Firefox didn't like the newline syntax. Odd, that.

    As for the output, Here 'tis. Again, a truncated list. Should I start drinking now?

    $VAR1 = { 'prilabst' => 0, 'firstname' => 'Test', 'OBJECT.listmenuid' => '1650', 'odetnone' => 0, 'useremail' => 'test@test.com', 'clntobid' => '2', 'objtocat' => 'User', 'directory' => 'testuser', 'objtotyp' => 'Users', 'PROCESS.javaloc.Pages1' => 'Pages1', 'OBJECT.directory' => 'testuser', 'email' => 'test@test.com', 'usroidst' => 1, 'password' => 'test', 'clientid' => '2', 'PROCESS.javaloc.Menus1' => 'Menus1',

    It's the little things that drive you crazy.

    Still, thank you so very much for your interest and assistance.

    FAX

      To me this really looks like there's some value in the keys/values which keeps perl from outputting the whole page.

      A) You could try to print only the keys and see which one comes after 'PROCESS.javaloc.Menus1'. This ~should~ print all 63 keys.

      Then you can change 'sort keys' into 'reverse sort keys' and if there's only one malformed key/value then you should end up with 46 lines of output. If there are less then that, then there are more then one bogus keys/values.

      B) Can perl write files to the filesystem? Normally the answer is yes, but you seem to be working on a webserver and who knows how it's configured. (Maybe someone really nailed it down and prevents write access to the filesystem via a SELINUX policy...)

      If you can write, then you could print your results to a file and check the contents of that file. At least you don't have to worry about proper HTML entity escaping, browser bugs and possible buffering issues.

      C) Do you have access to the webserver error log? If not: Get familiar with eval and catching exceptions and try to catch the error message, why perl terminates abnormally. Hint: Try::Tiny is really nice. The documentation also explains what can go wrong with eval. But pay attention to the trailing semicolon 'try {} catch {};' <--- Strange stuff happens if you ommit it.

Re^2: Incomplete Output When Printing Hash
by FAX (Novice) on Aug 18, 2013 at 20:27 UTC

    I can't thank you enough for your help on this insane situation.

    I am printing to the browser.

    The reason for this is that the SQL query and resulting hash is initiated by an online form submission (a log-in page, actually). The page has basic, simple input and I've used it without any issue. Anyhow, since I'm testing by submitting the form, it seems an easy matter to merely print the hash list to the browser window I'm already looking at.

    To be perfectly candid, that's how I've always reviewed things like this and have never had a problem in the past. It's what makes this particular deal so incredibly irritating. It's a very simple request ... print the hash to a browser page.

    Nevertheless, if I would be better off printing to the console, I must confess that, since I've never actually done that, I don't know how to do it. In the real world, this hash list must be generated by the form submission. That's why I test it the same way.

    I take it that you recommend I research means and methods for printing to the console, however?

    Thanks again (to all), FAX