> On Tuesday 29 June 2004 18:44, mohammed chafik wrote: > > That's what i've tried (may be it is not the best approch); > > If you ask me, the general approach is quite ok... >
<snip> > > > > > for ($i = 0; $i < 400; $i++) { > > The other source for the messages is that you're trying to access values in > the array @fields that do not exist. > In your data file, @fields holds something like 15 records, certainly not 400. > I'd do something like > > for (my $i = 0; $i <= $#fields, $i++) { > > which loops until $i has reached the last field of @fields ($#<array_name> > holds the last index of an array). > > > if( $fields[$i]=~ /subject/ ) { $k=$i} > > } > > Good suggestions, if we are going to stick with the loop, and we only care that we advance as long as we haven't found the subject then throwing a 'last' in after the assignment, would provide at least some speed up. If there are a significant # of lines to parse and the subject may appear early enough on the line then this could be a noticeable improvement. It would also make sense to adjust $i initial point forward if we can be guaranteed that subject occurs after a minimum number of fields on a line, which does seem indicated since we are using 0,2 indexes later not relative to the subject, so $i could be set at 3 initially. Turn my nitpicking back off now ;-)... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>