[Catalyst] Create multiple records

Will Smith willbelair at yahoo.com
Tue Jan 2 16:48:29 GMT 2007


oops, that a typo, sorry, I fixed that one. I realized it right after I sent the mail. The problem is it does not loop through the html page. this is what i done, and just the first value got inserted:
     my @records;
     my $book;
     foreach ( $book = (shift @{$c->request->params->{book}})){
 
     push @records, {title => $book};
     };
if, i try to put a second params, it just do nothing;
 push @records, {title => $book, price => $c->request->params->{price}};
 
 
"Hermida, Leandro" <Leandro.Hermida at fmi.ch> wrote:     Where did you declare @records?  I can't see that  in your code below but "my $record" could have been a typo and should read "my  @records".  You get that error in Perl when you try to use a variable that  is not declared (under use strict;) or the declared variable is then used  outside of its lexical scope.
  
 Leandro
  

       
---------------------------------
   From: Will Smith [mailto:willbelair at yahoo.com]    
Sent: Tuesday, January 02, 2007 16:54
To: The elegant MVC    web framework
Subject: Re: [Catalyst] Create multiple    records


   
happy new year to all of you.

thanks all for your support.    Back to the question, (which I guess, will irritate some catalyst/perl gurus -    but please be patient for learners), I've been able to add multiple records    with "PRE" assigned values. But that's not my purpose. I need to add multiple    rows that have the same name on the html. I tried several ways, but none was    good.

my $book;
my $record; 
foreach $book (    @{$c->request->params->{book}}){
  
       push  @records, {title => $book, price => $price    };
    };
   
          eval{
             $c->model('bookDB::Book')->create($_) foreach    (@records);
       };

---- this gives me    the compling error: Global symbol "@records" requires explicit package  name
_______________________________________________
List: Catalyst at lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070102/71dcddc7/attachment.htm


More information about the Catalyst mailing list