in reply to Help with Perl/Catalyst/Mason

First of all, please check the generated HTML (javascript) code, and see if there is anything abnormal about it. That is always your best bet to debug these sorts of things.

Second, you ought to learn how to use Mason as a templating language. The Mason book is available for free online reading. Please read about the different blocks available (<%args>, <%init> at the very least), and for $DEITY's sake, please do not embed that much code in the middle of your HTML. Mason is fairly good in separating code and HTML. Here's your code rewritten:

<%args> $foo $bar $baz $biz </%args> ... your html code ... deletes += <% $del_count %>; if(deletes > 0) { return confirm('Delete ' . + deletes + . 'Items? '); } ... your html code ... <%init> my @update = split(/,/, $biz); my $del_count = 0; if ($baz == 2 and and{ $tab_id == $_ } @update) { # ??? foreach ($foo, $bar) { $del_count += scalar split(/,/, $_); } } </%init>

I don't know what is wrong with your code, but I do wonder what and{ $tab_id == $_ } @update is supposed to mean...

Replies are listed 'Best First'.
Re^2: Help with Perl/Catalyst/Mason
by Anonymous Monk on Jun 30, 2012 at 10:36 UTC

    Oh, are you expecting that Perl code to run when you press Submit? I mean, asking for confirmation before the form is submitted?

      Yes, I was hoping that the perl would run when you pressed submit, beofre the form posts.
        aaaannnddd.... I just realized that wont work... I need to build the counts using JS....
Re^2: Help with Perl/Catalyst/Mason
by sharkeyph (Initiate) on Jul 02, 2012 at 19:03 UTC
    Thanks for the response... and{ $tab_id == $_ } @update = any{$tab_id == $_}@update. sorry for the typo. I am using this : List::MoreUtils qw( any ); Basically what it is doing is checking to see if the $tab_id value is located anywhere in the @update array. This allows me to control which tab the items are deleted from. Using the <%init> blocks like you have will the perl run prior to the deletes alert popping up? Thanks Again!!!