hi I'm PHP programmer. I don't know anything about Perl, I want this code in PHP.
Could anyone help me. its really very urgent.
Thanks in Advance
Perl Code:
#!/usr/bin/perl
#
=head1 NAME
loadniabarticles.pl - Website Database Load NIAB Articles Table Script
=cut
use lib
(qw(/home/bignm2/perl
));
{
use Website;
use Carp;
if (my $ws = new Website) {
open SESSION,
$ws->
{'config'}{'path_of_sessions_directory'} .
'/sessions';
opendir DIR,
"." or die "Cannot open current directory: $!";
die "Exiting - No Files Found." unless @files;
$ws->connectdb();
my $type = 'nichesinabox';
my $status = 'loaded';
my $table = 'articles';
my $where = '';
my $cols = 'MAX(id) + 1 AS nextid';
my $attrs = { 'nocommas' => 1 };
my $nextidref = $ws->selectdb($table, $where, $cols, $attrs);
$nextid = $nextidref->[0]{'nextid'} || 1;
foreach my $file (@files) {
my ($keyphrase) =
$file =~
m"^([-\w\s]+)\.txt"o;
$keyphrase =~
s"[-_]" "go; $keyphrase = $ws->trim(lc($keyphrase));
my $author = 'tomstraub';
my $title = '';
open FILE, $file or die "Cannot
open file
'$file': $!
"; my $content = '';
for (my $counter = 1; my $line = <FILE>; $counter++) {
chomp $line;
$title = $ws->trim($line) if $counter == 1;
next if $line =~ m"^\s*$"o or $counter <= 3;
$line =~ s"\r""go;
$line =~ s"\s*$""o;
$line =~
s/\x
{85}/.../go;
$line =~ s/\x{92}/'/go;
$line =~ s/\x{94}/"/go;
$line =~
s/\x
{A9
}/
(c
)/go;
$line =~
s/\x
{AE
}/
(R
)/go;
$line =~ s/\x{BB}/>>/go;
$line =~ s/\x{BC}/1\/4/go;
$line =~ s/\x{BD}/1\/2/go;
$line =~ s/\x{BE}/3\/4/go;
$line =~ s/\x{D7}/x/go;
$line =~ s/\x{F7}/\//go;
$content .= "$line\n";
}
close FILE;
my $colsref = {
'id' => $nextid++,
'keyphrase' => $keyphrase,
'title' => $title,
'content' => $content,
'type' => $type,
'status' => $status,
'author' => $author,
};
my @errors = $ws->insertdb($table, $colsref);
die $errors[0] if @errors;
}
$ws->disconnectdb();
close SESSION;
exit;
}
else {
die $!;
}
}