4 Replies Latest reply on Jul 21, 2008 11:42 AM by (jfrancis999)

    [JS] Basic questions: processing text file into associative array...

      Hi Guys,<br /><br />I'm coming from a PERL background so I'm probably looking at everything all wrong. I was hoping someone could help me with a basic workflow. I've got a plain text data file I want to read from of the format:<br /><br />String1<tab>Filename1.html<br /><br />I see that I can do something like this:<br /><br />var mymapfile = new File("mymapfile.txt");<br /><br />Now I've got a handle to the file.<br /><br />I then want to read line by line and create an associative array of the format:<br /><br />key(String1) --> value(Filename1.html)<br /><br />and I see that there's a <br /><br />var line = mymapfile.readln();<br /><br />and I'm guessing I can loop through the file until EOF is reached.<br /><br />I know I can use a regex like (^.*)\t(.*) to capture the key and the value from each line.<br /><br />I just can't seem to glue it together--I'd guess I'm thinking in PERL when I should be using a native JavaScript approach?<br /><br />Any guidance is greatly appreciated!<br /><br />Thanks!<br />John