Sam,
Thanks for responding.  I'm sorry if I don't understand the perl script 
enough to follow your attempt helping me.
It might be I didn't explain my task well enough.  In case it helps I'll be 
a little more descriptive.
Here is some of my xml structure:
<project>
<document id="KyChr-DB-B-001">
  ...
</document>
<document id="KyChr-DB-B-002">
  ...
</document>
<document id="KyChr-DB-B-002">
  ...
</document>
<document id="KyChr-DB-B-003">
  ...
</document>
  ...
etc through 250.
</project>

In this example I have two attributes of document with the id containing 
002.  I'm looking for a way of incrementing the number from the point of 
the duplicate so I don't have to manually change the remaining nearly 250 
by hand.  In my real document the duplicate is at about 40 so I would still 
have to change over 200 lines of text by adding one to the current value.

Does the script you posted help with this, and would I use it by placing in 
the BBEdit script folder in Application Support/BBEdit?
My applescript is weak and my Perl knowledge pathetic. In summary my goal 
is to have a script where I can highlight the part of the document that 
needs incrementing and have it change the numeric part of the string like 
"KyChr-DB-B-003" to "KyChr-DB-B-004" and increment the other strings 
similarly by one. Or have a script step through the document from the point 
of duplication and increment through the end of the file.

For this one time it would be quicker to just change it manually given the 
time I've spent trying to find a solution, but this issue is likely to 
occur again.
Anyway if you have any further suggestion, it is appreciated.  If not, 
thanks for taking the time to try.
Michael

On Saturday, June 11, 2016 at 6:34:09 PM UTC-4, Sam H. wrote:
>
> Indeed, Perl will help you here. Call it like this: 
>
> perl find-missing.pl 'KyChr-DB-B-(\d+)' < my_xml_file.pl 
>
> Will print just the numeric part of any missing entries. 
>
> Hope this helps. 
> -sam 
>
> #!/usr/bin/env perl 
>
> use strict; 
> use warnings; 
>
> my $pat = shift; 
>
> my $min; 
> my $max; 
> my %found; 
>
> while (<STDIN>) { 
>     chomp; 
>     if ($pat) { 
>         /$pat/; 
>         $_ = $1; 
>     } 
>     $min = $_ if not defined $min or $min > $_; 
>     $max = $_ if not defined $max or $max < $_; 
>     $found{$_}++; 
> } 
>
> foreach ($min .. $max) { 
>     print "$_\n" unless exists $found{$_}; 
> } 
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to