At 1:05 PM -0600 11/1/10, Doug McNutt sent email regarding Re:
Replace on Different Line Than Find?:
!/usr/bin/perl
undef $/; # Tell perl to ignore line ends in the input.
$thetext = <STDIN>; # read the whole document from standard input.
$e = "\n"; # Make it clear which line ends your document has in it.
You might want "\r" or "\r\n".
# Do the substitutions (s///) using the s flag to include line ends
and the g flag to repeat.
#begin single line that hopefully didn't get shortened by email.
$thetext =~ s/${e}movieYear : (\d\d\d\d)${e}(.*?)${e}title : ([\w
]*?)${e}/${e}movieYear : $1${e}$2${e}title : $3 \($1\)${e}/sg;
#end single line
print $thetext; # report the result to standard output.
__END__
I'm sure this will work splendidly, if only I knew what you were saying...
So, if I save the above script as TitleYear.pl and have two text
files to process, Phantom.txt and Kong.txt, how, exactly, would I
invoke it?
path/to/TitleYear.pl -w Phantom.txt Kong.txt
?
Call perl like this.
perl -w filename.pl < filename.pl
Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera
more lines
Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong
more lines
--
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>