At 18:39 -0400 1/11/11, Ronald J Kimball wrote:

Perhaps you meant something like this:

#! /usr/bin/perl
use strict;
my $switch_on;
while (<>) {
  $switch_on = 1 if /<caption>/;
  $switch_on = 0 if $switch_on && s/td>/th>/g;
  print;
}
__END__

Yes, except that I'd write 'and' and not '&&', not being much of a golfer.

You could implement that much more succinctly using Perl's flip-flop
operator:

#! /usr/bin/perl
use strict;
while (<>) {
  /<caption>/ .. s/td>/th>/g;
  print;
}

Very nice.

JD

--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
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>

Reply via email to