On Tuesday 27 April 2004 06:51 am, [EMAIL PROTECTED] wrote:
> Hi All,
> I have an web app that creates simple graphs. In one of the scripts I need
> to sort the data returned from the DB query numerically. I have a sub for
> this sort. I converted the script shown below from a regular cron job to
> embperl so I know that the perl works.
> The problem with the script below is that [ $ sub sortnum () $] prints on
> the screen and the image never gets created.
> The docs on
> http://perl.apache.org/embperl/pod/doc/doc13/HTML/Embperl.-page-5-.htm
> indicate that I have done it right.
> I have another script that is very similar to this without the sorting and
> it works just fine.
> What did I get wrong in this script.
> I am using embperl 1.36 on apache 1.3x
> Thanks.
> W
>
> [snipped]
>
> [ $ sub sortnum () $]
> [-  $a <=> $b; -]
> [$ endsub $]
>

Should the '()' be there?

[ $ sub sortnum () $]

maybe should be:

[ $ sub sortnum $]

I really don't see anything else. You might try

1) debugging (write to STDERR) - will show in error_log:

[- print STDERR "x array num elements before sort: ", scalar @x, "\n"; -]
[- @sortX = sort sortnum @x; -]
[- print STDERR "x array num elements after sort: ", scalar @sortX, "\n"; -]

2) try an aynonmous subroutine:

[- print STDERR "x array num elements before sort: ", scalar @x, "\n"; -]
[- @sortX = sort { $a <=> $b } @x; -]
[- print STDERR "x array num elements after sort: ", scalar @sortX, "\n"; -]

3) explicitly tell you are calling code:

[- print STDERR "x array num elements before sort: ", scalar @x, "\n"; -]
[- @sortX = sort &sortnum @x; -]
[- print STDERR "x array num elements after sort: ", scalar @sortX, "\n"; -]

Beware of my typos - I didn't test the above!

Alohs => Beau;

PS: you may want to save some keystrokes over long perl sections as:

[-
  perl statements;
-]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to