New Page 1< i'd like to know another way to do it, or another approach to reading the
info from the databse file
If I read you correctly, your datafile starts with : and ends with � , therefore your
data file would look like this :-
:This is the first data�
:This is the second data�
:This is the third data�
:fourth�
If the above is what you want, you can do this to search assuming you are searching
through a form :-
The only problem is that I do not know what to do if they submit the form with several
(not one) spaces at the beginning. Would appreciate members help on this matter.
#!d:\perl\bin\perl.exe -w
use CGI::Carp (fatalsToBrowser);
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
## Read Datafile
open (DATAFILE,"yourdata.txt") || die "$!\n";
@data =<DATAFILE>;
chomp @data;
# identify each record
@b = split (/�/, join ('', @data));
# Search the record
foreach $record (@b) {
$record =~ s/://;
if (grep /$FORM{'search'}/i, $record ) {
print $record;
};
};
I am just a beginner trying to help.
----- Original Message -----
From: "samuel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 11, 2001 2:26 AM
Subject: transforming an array of characters into 1 single string
Hi there!,
i'm developing a basic data base tool. the "search engine" i'm
trying to imlpement will read single characters from the source file
(where data is stored in :data� format). i asign every single
character betwwen the start ':' marker to the end '�' marker.
then, i try to turn the array of characters into a string variable like
this: $user[$y]= $data[0..$x], where $y is the
matrix entry where i want to insert the string,
and $x is the number of characters read by the
function.
i found out that was wrong, but...
.....Could anybody help me on that?
i'd like to know another way to do it, or
another approach to reading the info from the
databse file
thanx
Samuel Molina