in reply to READDIR and DBI
Something like:
my $path = '/home/marto/code/'; # open dir opendir(my $dh, $path) || die "Can't opendir $path $!"; # grep, testing for files my @files= grep { -f "$path/$_" } readdir($dh); closedir $dh; # connect to sqlite db my $dbh = DBI->connect('dbi:SQLite:dbname=filelist.sqlite','',''); # prepare insert my $sth = $dbh->prepare('insert into files(filename) values(?)'); # bind params $sth->bind_param_array(1, \@files); # execute $sth->execute_array({ ArrayTupleStatus => \my @tuple}) or die $sth->er +rstr;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: READDIR and DBI
by Anonymous Monk on Feb 26, 2024 at 17:51 UTC | |
by pryrt (Abbot) on Feb 26, 2024 at 20:53 UTC | |
by LanX (Saint) on Feb 26, 2024 at 18:27 UTC | |
by justin423 (Scribe) on Feb 26, 2024 at 18:05 UTC |
In Section
Seekers of Perl Wisdom