On Nov 01, 2016, at 00:28, Vlad Ghitulescu <[email protected] <mailto:[email protected]>> wrote: >> While Perl ordinarily operates on text on a per-line basis, I've used some >> tricks to make each search/replace line operate on the entire text in the >> script above. > > That is the "gm" in the Save-part respectively the "ig" for the others, right?
Hey Vlad, Nyet. #!/usr/bin/env perl -0777 -nsw -0777 changes the line separator to undef, letting us to slurp the file, feeding all the lines to Perl in one go. So – I've scarfed the entire text of the front BBEdit document into the default variable. Although the default variable is canonically represented by “$_” it can be assumed (not shown) in various types of code-blocks. This can be quite confusing to new users but is very convenient when writing terse code. https://www.tutorialspoint.com/perl/perl_special_variables.htm <https://www.tutorialspoint.com/perl/perl_special_variables.htm> > s!^Save \w.+[\n\r]!!gm; In this line I'm using the “m” flag to operate on multiple lines. That lets me use the beginning of line operator “^” to anchor “Save” to the start of any paragraph instead of the beginning of the entire string. -- Take Care, Chris -- 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]. Visit this group at https://groups.google.com/group/bbedit.
