RE: adding data to a file before it gets regexed



But whats your end goal? What is it going to do at the end?

-----Original Message-----
From: Pat Rice [mailto:patrick.j.rice@xxxxxxxxx]
Sent: 13 September 2007 14:16
To: Chas Owens
Cc: beginners@xxxxxxxx
Subject: Re: adding data to a file before it gets regexed

Thanks Chas for the reply

what I'm trying to do is add the file name to the start of the string beign
placed in the array, I havent used hashes so I'm not fiormlar with using
hashes, but I am open to using them.

The reasion I am trying to add the string to the line, is so that I can use
it in a regex afterwards, so it will break out what file was assiated with
the line, as I have a list of files that i am adding together.
I'm using opendir to get a list of files, then opening the files using open,
but I want to add the file to the string.

Thanks
Pat

On 9/13/07, Chas Owens <chas.owens@xxxxxxxxx> wrote:

On 9/13/07, Pat Rice <patrick.j.rice@xxxxxxxxx> 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.



This e-mail is from the PA Group. For more information, see
www.thepagroup.com.

This e-mail may contain confidential information. Only the addressee is
permitted to read, copy, distribute or otherwise use this email or any
attachments. If you have received it in error, please contact the sender
immediately. Any opinion expressed in this e-mail is personal to the sender
and may not reflect the opinion of the PA Group.

Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.




.



Relevant Pages

  • Re: adding data to a file before it gets regexed
    ... hashes, but I am open to using them. ... The reasion I am trying to add the string to the line, is so that I can use ... it is not a good idea to store entire files in memory and it is really ... the arrays are the contents of the files broken down by lines. ...
    (perl.beginners)
  • Array table
    ... I had 4 arrays ... string FirstName; ... string BirthDay; ... What is the good way to store these information in a table? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need a little help
    ... for the information to add to the arrays. ... JTextPane textPane = new JTextPane; ... String newArtist = JOptionPane.showInputDialog(null, "Please enter ... }//end public void actionPerformed ...
    (comp.lang.java.programmer)
  • Need a little help
    ... for the information to add to the arrays. ... JTextPane textPane = new JTextPane; ... String newArtist = JOptionPane.showInputDialog(null, "Please enter ... }//end public void actionPerformed ...
    (comp.lang.java.programmer)
  • Re: Storing a value for later use in vba or a Macro
    ... Dim strCurrentCustomer as String ... do you programmatically store a value from one record to use in ...
    (microsoft.public.access.gettingstarted)