aa22abc862
Utworzono katalog tools, w ktorym znajduje sie skrypt ulatwiajacy dodawanie ksiazek, w przyszlosci prawdopodobnie znajda sie tam rowniez inne narzedzia.
34 lines
591 B
Perl
Executable file
34 lines
591 B
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
use strict;
|
|
use strict 'vars';
|
|
|
|
use DBI;
|
|
|
|
my $dbfile = 'ksiazki.db';
|
|
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
|
|
|
|
my($id,$isbn,$title,$author,$owner,$state,$who,$can_borrow,$reserved,$comment);
|
|
|
|
|
|
open (INPUT,"ksiazki");
|
|
|
|
my $_ = <INPUT>;
|
|
|
|
while ($_)
|
|
{
|
|
($id,$isbn,$title,$author,$owner,$can_borrow) = split(/,/,$_);
|
|
chomp $can_borrow;
|
|
if($can_borrow eq 'Tak')
|
|
{
|
|
$can_borrow = 1;
|
|
}
|
|
else
|
|
{
|
|
$can_borrow = 0;
|
|
}
|
|
$dbh->do("insert into ksiazki values ($id,$isbn,'$title','$author','$owner',1,'nikt',$can_borrow,0,'')");
|
|
$_ = <INPUT>;
|
|
}
|
|
|