xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
questions:#!/usr/bin/perl #use Getopt::Long; use strict; use File::Find; use DBI qw(:sql_types); my @search_result; # find files find (\&wanted,"."); #save to database. foreach (@search_result) { my @file_stat = stat; save_data(@file_stat,$_); } sub wanted { if(/\.pl$/i) { push @search_result,$File::Find::name; } } sub save_data { my $sql = q(insert into file_stat values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)) +; my $dbh = DBI->connect('dbi:ODBC:test','test','test123',{AutoCommi +t => 1,RaiseError => 1}) or die "error!!\n"; my $sth = $dbh->prepare($sql); my $count = 1; foreach (@_) { if($count==14) { $sth->bind_param(14,$_); } else { $sth->bind_param($count,$_,SQL_INTEGER); } $count ++; } $sth->execute; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regarding File::Find
by chromatic (Archbishop) on Nov 17, 2006 at 07:00 UTC | |
by xiaoyafeng (Deacon) on Nov 17, 2006 at 07:21 UTC | |
by Hofmator (Curate) on Nov 17, 2006 at 09:46 UTC | |
Re: regarding File::Find
by quester (Vicar) on Nov 17, 2006 at 07:13 UTC | |
Re: regarding File::Find
by inman (Curate) on Nov 17, 2006 at 12:59 UTC |