This doesn't have anything to do with CGI so would be better directed to [EMAIL PROTECTED] instead....
> > I have been studying W/R to files... > W/R to a string and to an array. > and I must say I think I have it. > > I can read a file into an array IF i wrote the file using "\n" between vars, yes???? Yes and know. You don't have to have any newlines in the file to read it into an array, but all of the content will appear in the first element of the array in that case. Reading/writing a file is lower level than that and doesn't specifically care about the contents.... having said that, if the file is read/write in a manner that will allow buffering you might have to have flushing turned on. > > and I can read the entire file into a string (to later be split) by using delimiters like "," yes??? Again delimiters don't affect the reading. However by using delimiters you can allow any string to be split. > > I have some data files that hold lists (like cities) that I want in an array. > and some files that hold a collection of vars (name, city, color, cartype, etc) that I want to delimit and later read as a string ($Slurp) and then ($name, $city, $color, $cartype, $etc)=split (",",$Slurp) > > my question is if I write a file using delimiters like "," can I later read the entire file into a string and then > @Cities = split (",",$Slurp) ?????? Assuming they were all on one line. In this case I would suggest putting each city on its own line and reading the file at once into an array, no split would be needed. > > but how do I read a file that used the "\n" and then split it later??? > right now i wold have to > open file... > @Array=<read entire file into @Array> > close file > > and then... > > $name=$Array[1]; > $city=$Array[2]; > $color=$Array[3]; > $cartype=$Array[4]; > $etc=$Array[5]; > > there must be a better way like ????? > $name, $city, $color, $cartype, $etc)[EMAIL PROTECTED]; > The above will work, you can also store it directly from the <HANDLE> since it is list context, but in that case you need to be sure the file has the right number of lines. > of can I split using the special var $\ or \n as a delimiter???????? > I believe you mean $/ which is the input record separator. For more information on it see the INPUT_RECORD_SEPARATOR section in, perldoc perlvar Essentially it sets the delimiter used when Perl reads the file to automagically delimit it. > ?????????? am I making the example clear????????? > or am i trying to do the impossible? > Nothing is impossible ;-). Not sure about the clarity though, some sample code and an example file would be helpful. > Comment WITH example correction welcome.. > the above syntax may not be completely correct.... > but it gives you the idea...so please dont crusify me for it... > > Lou > > I would suggest some further reading on the subject first, perldoc perlopentut perldoc -f open perldoc -f split perldoc -f readline Also check out the "I/O Operators" section of, perldoc perlop HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>