Code Comments
Programming Forum and web based access to our favorite programming groups.I am extracting certain info from a text file. I want to grab the
second line(without spaces) in the following text and push it into an
array. ( I know how to get it into an array, but my problem is telling
it to go to the next line.
---------------------------------------------------------------------------
13. Subject or Title of Occurrence:
Collapse of Contractor Employee while working out
----------------------------------------------------------------------------
This is what I have done to identify the line perusing through each
line
if (/Subject or Title of Occurrence:/)
{
do something;
}
Any help is appreciated.
Thanks,
umpty
Post Follow-up to this messageOn Wed, 20 Apr 2005 09:28:44 -0700, umpty wrote:
> I am extracting certain info from a text file. I want to grab the
> second line(without spaces) in the following text and push it into an
> array. ( I know how to get it into an array, but my problem is telling
> it to go to the next line.
>
> --------------------------------------------------------------------------
-
> 13. Subject or Title of Occurrence:
> Collapse of Contractor Employee while working out
> --------------------------------------------------------------------------
--
>
> This is what I have done to identify the line perusing through each line
>
> if (/Subject or Title of Occurrence:/)
> {
> do something;
> }
>
> Any help is appreciated.
> Thanks,
> umpty
You could do something like this:
my $match = 0;
if (/Subject or Title of Occurrence:/)
{
$match = 1;
next;
}
if ($match) {
# put wanted data into array
last;
}
Warning this is untested and will probably only work with your very
specific example. I'll leave it to you see where the potential pitfalls
are (ie. how do you switch off the $match if you want to match multiple
items?).
HTH
Chris.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.