Elijah has asked for the wisdom of the Perl Monks concerning the following question:
Now the problem is when I use the $t->get function it does load the entire contents of field $t into the array but when I try to foreach each line the array is not broken into different lines it seems. I toss some debugg print statements in there as you can see and it appears the value of $_ is the entire contents of the array instead of just the first line in the array. The problem is a problem because I need the array to be broken into each line so I can increment the count so I can return the matched line and what line number it was found on. But as far as the loop is concerned the array has only one object therfore the line count never increments past one (the default). How can I perform this function the way I need to?my @field = $t->get("1.0", "end"); foreach $_ (@field) { if ($_ =~ "\\b$string\\b") { print "Found $string in $_\n"; print $count,"\n"; $status->insert("end", "Found on line " . $count,"\n"); &go_to($count); last; } $count++; print "Count equals $count\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: foreach increment problem?
by Roy Johnson (Monsignor) on Dec 05, 2003 at 18:50 UTC | |
|
Re: foreach increment problem?
by tcf22 (Priest) on Dec 05, 2003 at 18:52 UTC | |
|
Re: foreach increment problem?
by Zed_Lopez (Chaplain) on Dec 05, 2003 at 18:55 UTC | |
by Grygonos (Chaplain) on Dec 05, 2003 at 19:41 UTC | |
by Elijah (Hermit) on Dec 05, 2003 at 19:44 UTC |