in reply to Updating database question

You may want to look at something like Class::DBI or Tie::DBI to do the grunt work for you. But, to answer your question, yes you will need to add an UPDATE statement to the code you posted in order for your code to do what you want.

Seriously, I'd use Class::DBI.

foreach my $row (MyCDBI::Class->retrieve_all) { if ($row->column1 =~ m/AR/i ) { $row->column2( 'AR' ); } $row->update; }
Done. :-)

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^2: Updating database question
by curtisb (Monk) on Jun 30, 2005 at 18:47 UTC
    Do you mean I will need to write a sub-function to do the update and then call it after I set the value?
    Bobby
      inline or another sub is a matter of preference. My code example was how easy it would be to do what you're trying to do if you were using Class::DBI instead of directly using DBI.

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?