vage78
asked on
I want to search through an asci file
I'm a new programmer in Perl. I have a ascii file with 20000 records. How i can make searches inside this file with one or two fields. Which are the steps?
May i have a simple example of this type of program.
Thank you
May i have a simple example of this type of program.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much.I will try.My file is very big. Is this a problem? (20000 records) or everything is ok.
May i use also indexes.
Thanks a lot
May i use also indexes.
Thanks a lot
>> My file is very big. Is this a problem? No
>> May i use also indexes?
Please explain what you mean.
>> May i use also indexes?
Please explain what you mean.
If so, what is used to separate the fields?
Here is an example where the fields are separated with a '|' character.
Assume you want the first field to be "Person" and the third field to be "Every month":
$Record0Search = "Person";
$Record2Search = "Every month";
open(FILE, "data.txt");
while ($Line = <FILE>) {
@Fields = split '\|', $Line;
print $Line if (($Fields[0] eq $Record0Search) && ($Fields[2] eq $Record2Search));
}