Access and PERL Question

dejones923

New member
Local time
Today, 17:47
Joined
Mar 7, 2008
Messages
6
I am trying to replace a tab characters from a string with nothing, see below:

"tab1 here" SCOPING AND SCREENING RESULTS: ELECTRICAL AND INSTRUMENTATION "tab2 here" "tab3 here" AND CONTROLS SYSTEMS

The following line of code removes all but tab3. I have checked to see that it is a tab using the asc function in VBA, and indeed it is ascii code 9.

$test = ($value2 =~ s/([\t]+)//g);

Here is my code:

use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';

close OUT, "Results.txt" or die $!;
open OUT, '>Results.txt' or die $!;

my $database = "GailTest.mdb";
my $table = "tblOSRP_LR";
my $field1 = "SRPID";
my $field2 = "SRPTitle";

$Conn = Win32::OLE->new("ADODB.Connection");
$RS = Win32::OLE->new("ADODB.Recordset");

$DSN = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=$database;UID=;PWD=;";
$Conn->Open($DSN);

$SQL = "SELECT $field1, $field2 FROM $table";

$RS->Open($SQL, $Conn, 1, 1);

while (! $RS->EOF)
{
my $value1 = $RS->Fields($field1)->value;
my $value2 = $RS->Fields($field2)->value;
$test = ($value2 =~ s/([\t]+)//g);
print OUT "$value1" ." ". "$value2\n";
$RS->MoveNext;
}

$RS->Close;
$Conn->Close;

Any help would be greatly appreciated.
Thanks
 

Users who are viewing this thread

Back
Top Bottom