jsteng has asked for the wisdom of the Perl Monks concerning the following question:
Unfortunately this $list->index("T$j.first") || '1.0' fails if tag $j does not exists. How do I check for the existence of a tag ($j) in said list?my $ip = $list->index("T$j.first") || '1.0'; #preserve insertion p +oint #if insertion point is not found, then use 1.0 as insertion point. $list->delete("T$j.start", "T$j.last"); $list->insert($ip, "next text here");
foreach my $i ($list->tagNames()) { if ($i eq $j) { print "$tag found\n"; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: checking existence of a tag in a TK::Text?
by kcott (Archbishop) on Apr 29, 2018 at 08:41 UTC | |
by jsteng (Beadle) on Apr 29, 2018 at 09:24 UTC | |
|
Re: checking existence of a tag in a TK::Text?
by zentara (Cardinal) on Apr 29, 2018 at 19:42 UTC | |
|
Re: checking existence of a tag in a TK::Text?
by Anonymous Monk on Apr 29, 2018 at 13:44 UTC | |
by jsteng (Beadle) on Apr 30, 2018 at 06:30 UTC | |
by Anonymous Monk on Apr 30, 2018 at 08:49 UTC |