At 8:42 AM +0100 11/2/10, John Delacour sent email regarding Re: Replace on Different Line Than Find?:

Here's a way to do it using a UNIX filter on an open BBEdit document:

(Filename: "p.pl")

#!/usr/bin/perl
use strict;
my $year;
while (<>){
  m~^(movieY.+)([0-9][0-9][0-9][0-9])[ \t]?~i and $year = " ($2)";
  s~^(title.*)~$1$year~;
  print;
}

As expected, the above works as a Unix filter in BBEdit.

This line:
m~^(movieY.+)([0-9][0-9][0-9][0-9])[ \t]?~i and $year = " ($2)";
appears to set the var $year to the four digits within parentheses. What does the "[ \t]?~i " part do?

In terminal, the output goes to STDOUT. How would I get it to replace in place, updating the file?

--
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to