...

View Full Version : Scan a .txt file



moisesbr
01-06-2010, 07:06 PM
Hi

I have a .txt file with contains fields separated by ;
as below

name; city; course; address; etc


I want to built a CGI script based on the algorithm below
to look if have a student is enrolled in a course

************************************************
scan the .txt file from top to bottom

If line contains $student_name and $student_course

print '<p align="left"><font face="Arial">Found: '$student_name '</big></font></p>'."\n" ;

continue the scan

If line contains $my_name and $my_city

print '<p align="left"><font face="Arial">Found: '$student_name '</big></font></p>'."\n" ;


*****************************************************

I came from visual foxpro with little experience in web languages


Moises

FishMonger
01-11-2010, 05:30 AM
What have you tried?

What part of the task do you not know how to do or is giving you trouble?

moisesbr
01-12-2010, 12:15 PM
What have you tried?

What part of the task do you not know how to do or is giving you trouble?

Hi

There are two steps

1) I would like to import the txt file into an array where each field of the
txt (separated by semicolon) will be a column of the arry, and each line of the .txt
will be a line of the array

2) I would like to scan the array looking for situations where two columns
of the array match the variables I am lookig for

For example: If colunm1 = $city and column2 = $student

write: Studend $student found





Moises

FishMonger
01-12-2010, 02:32 PM
That doesn't answer my question and this looks like your homework assignment.

1) You need an Array-of-Arrays. See:
perldoc perldsc
http://perldoc.perl.org/perldsc.html#ARRAYS-OF-ARRAYS

perldoc -f open
http://perldoc.perl.org/functions/open.html

2) You need to loop over the array and test the desired fields.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum