Home: Perl Programming Help: Intermediate:
Doubt in Perl



rajsalem
Deleted

Jun 6, 2000, 2:50 AM


Views: 1307
Doubt in Perl

Hi ,

How to open a .DOC file through a perl program and to copy the same .doc file to other file through Perl program? and also i want to insert this into mysql database.
Kindly reply us soon as the matter is urgent.
Thanks
Rajkumar


Cure
User

Jun 15, 2000, 9:31 AM


Views: 1307
Re: Doubt in Perl

Something like this ->

use File::Copy;
use DBI;
use CGI ();

copy("file1","file2");

my $DSN = "DBI:mysql:test";
my $user = "username";
my $pw = "secret";
my $q = CGI->new;

my $dbh = DBI->connect($DSN) or die "Cannot connect: $DBI::errstr\n";

my $query = q!INSERT INTO table_name (column_one)
VALUES ("file2")!;

my $sth = "$dbh->do($query) or die "Could not prepare '$query'. Reason: '$DBI::errstr'";

$dbh->disconnect;

Cure