$query = $db->query($sql_query);
$number = $query->affectedrows
the variable $sql_query is a string, and contains your SQL syntax for your query. There is no semi-colon at the end of the query in this case though. You can directly insert the string if you like as well, instead of using $sql_query.
The variable $query now contains the identifier for the query, and will be used from now on for accessing that query's data.
$number contains the number of rows in the database affected by query.
Comment on Re: Perl and MySQL: Get number of rows affected