1 Replies - 3260 Views - Last Post: 29 June 2012 - 06:57 PM

#1 sharkeyph  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 37
  • Joined: 28-March 11

Perl / Mason / Catalyst help

Posted 29 June 2012 - 06:33 PM

Hey guys,

So I have run into a weird issue and was wondering if anyone could help me... I have a segment of code which is designed to test data using PERL in a MASON file. The concept is that when the user enters a item for deletion, the PERL code identifies it and alerts the user to the number of items to delete...

Here is the code:

   my $foo = $c->req->param('foo');




Is This A Good Question/Topic? 0
  • +

Replies To: Perl / Mason / Catalyst help

#2 sharkeyph  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 37
  • Joined: 28-March 11

Re: Perl / Mason / Catalyst help

Posted 29 June 2012 - 06:57 PM

// I pressed the submit button on accident... Here is my ACTUAL post lol

Hey guys,

So I have run into a weird issue and was wondering if anyone could help me... I have a segment of code which is designed to test data using PERL in a MASON file. The concept is that when the user enters a item for deletion, the PERL code identifies it and alerts the user to the number of items to delete...

Here is a breakdown of the code:

  
%   #   my $tab_id is set higher in the code^^^/> 
%   my $foo = $c->req->param('foo');
%   my $bar = $c->req->param('bar');
%   my $baz = $c->req->param('baz');
%   my @update = split(/,/, $c->req->param('biz'); #this is an array of place to delete 
                                                  # the items
%   if ( ($foo) && ($baz == 2) && (and{$tab_id == $_}@update) ) {
%       my @delete_items = split (/,/, $foo); 
%       my $del_count = scalar(@delete_items);
        deletes += <%$del_count%>; # this is setting the JS variable for the counts
%   }
%   if ( ($bar) && ($baz == 2) && (and{$tab_id == $_}@update) ) {
%       my @delete_items = split (/,/, $bar); 
%       my $del_count = scalar(@delete_items);
        deletes += <%$del_count%>;
%   }
 ---------------------------------------------------------------------------------
    // javascript section:
    if(deletes > 0) {
        return confirm('Delete ' . + deletes + . 'Items? '); 
    }   



for a bit of context here $foo, $bar are the input from the form and this section of code is executed along with other stuff on the user hitting submit on the form. My issue is that the code works, but it doesn't alert properly.

its a bit hard to explain so I will just give an example..

Say I enter 3 items to be deleted and press submit. No error will pop up to alert me. But say I go back to the page and try to delete a single item, the alert will pop up and say 'Delete 3 Items? '

When I dump the variable contents to the log, the variables contain data from the first submission and not the second (correct) submission.

This continues... Every time I do an operation on the page, the data that the alert operates on is one 'session' behind... The alert works, and it is getting the expected data but just needs to operate on the correct update...

I am unsure if this is an issue with the way Catalyst is handling the data or what, but I could sure use some help...

Thanks!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1