in reply to regarding File::Find

Answer #1: you can do your insert within wanted().

Answer #2: pass a list of values to execute() instead of using bind_param() and counting.

Replies are listed 'Best First'.
Re^2: regarding File::Find
by xiaoyafeng (Deacon) on Nov 17, 2006 at 07:21 UTC
    Thanks for your reply!

    I think my mention has some problems.

    for 1, I mean "insert" and "find" are running in parallel.
    for 2, if use execute,how declare sql_type?
      I think the solution chromatic had in mind goes something like this (untested)
      #!/usr/bin/perl use strict; use File::Find; use DBI; my $sql = q(insert into file_stat values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)) +; my $dbh = DBI->connect('dbi:ODBC:test','test','test123',{AutoCommit => + 1,RaiseError => 1}) or die "error!!\n"; my $sth = $dbh->prepare($sql); sub wanted { return unless /\.pl$/i; my @stats = stat $File::Find::name; $sth->execute(@stats, $File::Find::name); } # find files find (\&wanted,".");

      Update: fixed stupid mistake in code (return instead of next).

      -- Hofmator

      Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.