On 01/12/2019, at 19:32, Dj <[email protected]
<mailto:[email protected]>> wrote:
> I'm only trying to change space between words and not carriage returns and
> all that. So far I've tried placing this in the scripts folder:
>
> perl -pe 's/ +/ /g'
Hey Dj,
The code you have above is the sort of thing that would normally be embedded in
a shell script or used directly from the command line.
Here's a more normal Perl script that would be used as a text-filter in BBEdit,
and it does exactly what your code above does.
* Lines 2-5 are optional depending upon what you're doing, but I'm allowing for
UTF8 text requiring that the Perl used be at least v5.010 (which is pretty old
by now)
#!/usr/bin/env perl -sw
use v5.010;
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
while (<>) {
s/\h+/ /g;
print;
}
The -p switch in your script above stands in for this while structure, and it
provides for the script to die quietly when it runs out of data to process.
That exact structure looks like this:
#!/usr/bin/env perl -sw
while (<>) {
# your program goes here
} continue {
print or die "-p destination: $!\n";
}
The -e switch in your script above stands for execute, so Perl knows to execute
the quoted text.
You can find all of the command line switches by pasting “perldoc run” into the
Terminal and typing Return.
You can also paste “perldoc run” into a BBEdit Shell Worksheet, make sure the
cursor is on that line, and hit Enter.
This will give you the same text as in the Terminal, but you'll have access to
BBEdit's search functions.
--
Best Regards,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://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.