On 9/13/07, Pat Rice <[EMAIL PROTECTED]> wrote: > hi all > I have the following problem. > I'm trying to read the a file in line by line. using a for each statment, > but I want to modify each line as it come in so that I can add the file > name that I am looking in to the line. > > eg. looing in file1.txt we have the line "hello world" > > I want to do the following: > hello world > becomes...... > file1.txt hello world snip
I don't understand what you are trying to accomplish. Are you trying to modify the original file or just store files data in your program with the files name attached? If you are trying to do the latter then it is not a good idea to store entire files in memory and it is really not a good idea to add the file name to each line of the file. A better design would be a hash of filehandles whose keys are the names of the files you want to read from, or, if you really need to store the files in memory, a hash of arrays whose keys are the filenames and the arrays are the contents of the files broken down by lines. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/