robic0 wrote:
> On 14 Feb 2006 19:23:14 -0800, "it_says_BALLS_on_your_forehead" <> wrote:
>
> >
> >Jim Gibson wrote:
> >> In article <43f2374f$0$23279$>, Obantec Support
> >> <> wrote:
> >>
> >> > Hi
> >> >
> >> > i am reading data from a mysql source and i need to on certain lines when a
> >> > match occurs read the next few lines and output if not blank, then continue
> >> > the loop.
> >> >
> >> > all lines have text except for the odd blank line.
> >> >
> >> > i am using
> >> >
> >> > $nic_nam="ShowMe";
> >> >
> >> > foreach $i (@result)
> >> > {
> >> >
> >> > if ($i=~ m/$nic_nam/) {
> >> >
> >> > print "Found SHowMe<br>\n";
> >> >
> >> > #now if this matches out put the next few lines while not blank from
> >> > @results
> >> > #max is only ever 7 lines.
> >> >
> >> > }
> >> > }
> >>
> >> Use a C-style for loop (untested):
> >>
> >> for( my $i = 0; $i < @result; $i++ ) {
> >> if( $result[$i] =~ /$nic_nam/ ) {
> >> print "Match found: $result[$i];
> >> while( $result[$i+1] != /^\s*$/ ) {
> >> print $result[++$i];
> >> }
> >> }
> >> }
> >
> >this fails to conform to the behavior specified by the OP on arrays
> >that contain strings matching the pattern in adjacent indices.
> >
> >for instance:
> >
> >my @data = qw( zero pattern1 pattern2 three four );
> >
> >assuming that 'next few' is 2, the output based on the OP's description
> >should be (since there are no blanks):
> ># matches pattern1, so prints the following 2 lines...
> >pattern2
> >three
> >
> ># continues loop, starting from where we left off before (OP a little
> >unclear here though)
> ># so now at pattern2, and matches again, so prints the next 2 lines...
> >three
> >four
>
> There is no conformity on the OP's statements. The OP's statements have
> conceptual errors. Why try to read into an errant proposition.
> A test of a good programmer is to take in the whole proposition and make
> an immediate analysis/assesment of the completeness of if or otherwise.
> A single read of the statement and you realize its an incomplete thought.
>
> Unless your bored and young, why try to make it into a federal case?
> There's many years ahead that will bust your nut on big programming asignments
> to get worked up with this.
>
i'm not making anything into a federal case. i'm trying to be as
meticulous as possible because *not* being meticulous is precisely what
will "bust my nut" on big programming assignments.
if i make an error, i hope that someone will point it out so i won't
make it again, and so i can go back and fix code that is a timebomb
waiting to explode.
> Let it go. If its not obvious whats wrong then just ask.
|