> is there a way to tell the program to
> "read until you see this line and
> place everything you have read up to
> that line into @array"

# yes.
my @lines = ();
open IN, "somefile" or die $!;
while (<IN>) {
  last if /some_match/;
  pusdh @lines, $_;
}
close IN;

> could this start at the bottom of the file
> and read backwards

Nothing built in.  A quick search of CPAN shows a module called
File::ReadBackwards.

http://search.cpan.org/author/URI/File-ReadBackwards-0.99/


Hope that helps.

Rob



-----Original Message-----
From: Jamie Bridges [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 2:08 PM
To: [EMAIL PROTECTED]
Subject: parsing text files ... 


i have admittedly been lurking for awhile on this list b/c all of your
advice has been helpful as reference in building some of my code.  i
haven't seen anything since i joined the list which could help me with the
following problem so i hoped maybe you guys could address it for me.

what i have is text files we created using a bourne shell script.  we chunk
together output from a solaris box into a standard format ( prtdiag | dmesg
| format ) and then place this file on a server.   we're writing a utility
to unchunk this data and place it directly into individual cells in a mysql
database.

is there a way to tell the program to "read until you see this line and
place everything you have read up to that line into @array" ...also could
this start at the bottom of the file and read backwards up to a certain
line?

my big hang up that follows this problem is that these files are obviously
dynamic and therefore can be of different lengths, and in some cases can
also include drastically different information.   in looking through many
examples however, i have found lines which start and stop each portion that
i can use as "end points" in my searching.

i would post code but at this stage i don't have anything written past the
initial :

open( FILE, $file );
while ( <FILE> ) {
      push( @masterlist, $_ );
}
close( FILE );

any advice that could be offered would be helpful.
-----------------------------------------
Jamie Bridges
Asst. Sun Hardware Lead




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to