Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: having problem in displaying large size of variable on web page

by perlfan (Vicar)
on Sep 27, 2007 at 13:51 UTC ( [id://641352]=note: print w/replies, xml ) Need Help??


in reply to having problem in displaying large size of variable on web page

Even in CGI scripts, you should use strict; and use warnings;. This could help you right off the bad.

Does this work if the contents of the variable are small? In other words, are you positive it is related the size of the variable and not something that you're doing incorrectly in the script? Just because it prints at the command line doesn't mean it'll come through when calling it through the web server.

I also noticed that $retHashRef{$viewItem[0]} = $viewStr; should be $retHashRef->{$viewItem[0]} = $viewStr; ... unless $viewItem is itself an anonymous array ref, which would mean you'd have to use $viewItem->[0].

We can't really help with out more code.

Replies are listed 'Best First'.
Re^2: having problem in displaying large size of variable on web page
by graff (Chancellor) on Sep 27, 2007 at 17:11 UTC
    Even in CGI scripts, ...

    I would rephrase that:

    Especially in CGI scripts, ...

    And I would add: Always do "perl -T -cw my_cgi_script" in a command-line shell before you make it runnable on a web server, to make sure it compiles with taint checks in effect.

    (update: a lot of taint checks can only be applied at runtime, and I'm not sure I can identify any compile-time taint checks, but your cgi script should have "-T" in the shebang line, and when that's true, a shell command line like  perl -cw my_script won't work.)

Re^2: having problem in displaying large size of variable on web page
by perlCrazy (Monk) on Sep 28, 2007 at 05:47 UTC
    Thanks for response.
    yes it does work with small string. I have updated my post and also posted portion of code that does display on browser.
      Thanks for the update. But I'm still a little confused about your code. You say that the last snippet produces the intended display for a small amount of data, so it seems like your problem arises when you try to display a large amount of data. I think that makes sense.

      So, one way to look for a solution is to figure out how to get the job done with less data being sent to the browser (and maybe with less data being handled by the server, too).

      As I said before, your "P3::util::HTML" module is unknown to the rest of us; if you don't want to start putting that code up for public review, that's okay, but you're on your own if that module turns out to be part of the problem. I noticed that there was a difference in how the two snippets use it:

      # original snippet (with the large amount of data, not working): foreach my $row (keys %$dbDDL) { push @rowArr, '<pre> ' . '<font size=2>' .$dbDDL->{$row} . '</font>' +. '</pre>' ; &P3::util::HTML::doTableDetailRow($altColor, @rowArr); } # update snippet (working with a small amount of data): foreach my $row (keys %$dbDDL) { &P3::util::HTML::doTableColAttributes(''); $altColor = !$altColor; my @rowArr; push @rowArr, '<pre> ' . '<font size=2>' .$dbDDL->{$row} . '</font +>' . '</pre>' ; &P3::util::HTML::doTableDetailRow($altColor, @rowArr); }
      The difference is that in the first snippet, @rows gets larger by one entry on each iteration, whereas in the second one, it's always a brand new array, with just one entry in it -- in effect, you could be passing a scalar (not an array) to "doTableDetailRow()".

      If the function really takes a "color" spec and an array (i.e. a list of strings) as its parameters, the list is either for cells on a row or for rows in a table. If it's supposed to take a list of cell values for one row, then the first snippet above is just wrong and will not display the data correctly -- and if you are handling 2 MB per entry in @row, it's disastrously wrong:

      <table> <!-- first iteration: --> <tr><td>... 2MB string </td></tr> <!-- second iteration: --> <tr><td>... 2MB string </td><td>another 2MB string</td><tr> <!-- and so on ... --> </table>

      For now, you are the only one in this discussion who can know the correct usage for that module. If you don't know, I hope for your sake that it's documented somewhere so you can RTFM.

      In the meantime, you should still look into figuring out what the user of this web service is supposed to accomplish, and see if you can figure out how to enable that without requiring the person to scan megs of data in a table on his browser window.

        Thanks for your response. Yes, I am looking for some work-around and trying to find some other solution for this requirement.
        May be I can write the data into a file then provide the option for download that file.
        Thanks for advice and help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://641352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found