Not tested, but should give you an idea of how to proceed. (Sorry for the golf,
I couldn't resist.)
-sam
#!/usr/bin/env perl
use strict;
use warnings;
my $next;
while (<>) {
($next = $_) =~ s/(\d+)/$1+1/ge;
print;
}
print $next;
On October 13, 2015 6:04:22 PM EDT, "@lbutlr" <[email protected]> wrote:
>I have the following text-filter:
>
>#!/usr/bin/perl -w
>
>while(<>) {
> my $line = $_;
> $line =~ s/(\d+)/($1 + 1)/ge;
> print $line;
>}
>
>Which doesn’t exactly do what I want it to do, in that it increments
>the number on each line (or each selected line) and what I want is for
>the script to create a NEW line with an incremented number.
>
>For example, if I have a file that contains
>
>
>Text 980
>Text 981
>
>Then running the script would yield:
>
>Text 980
>Text 981
>Text 982
>
>It would be even better if it could ask how many new lines I want so I
>could add 100 or 1000 incremented lines all at once.
>
>I’m sure this has been covered on the list before, but I can’t seem to
>find it.
--
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].