______________________________________________________________________
Hey Shawn,
Just in case this is something you need to do on a regular basis (and for fun), I've written a couple of text-filters and an Applescript to do the job.
Keep the principles in mind, as they're easily adapted to other tasks.
--
Best Regards,
Chris
-------------------------------------------------------------------------------------------
Very Basic Perl Text-Filter:
#! /usr/bin/env perl
use strict; use warnings;
my $cntr;
$cntr = 1;
while (<>) {
chomp;
print;
if ($cntr < 4) {
print "\t";
$cntr++;
} else {
print "\n";
$cntr = 1;
}
}
Basic Perl Text-Filter Using an Array:
#! /usr/bin/env perl
use v5.010; use strict; use warnings;
my (@reco, $cntr);
$cntr = 1;
$, = "\t";
while (<>) {
push @reco, $_;
if ($cntr == 4) {
chomp @reco;
say @reco;
@reco = ();
$cntr = 1;
} else {
$cntr++;
}
}
#! /usr/bin/env perl
use strict; use warnings;
while (<>) {
chomp; print;
if ($. % 4 != 0) {
print "\t";
} else {
print "\n";
}
}
Applescripting the Regular Expression (with basic error-checking):
-------------------------------------------------------------------------------------------
try
tell application "BBEdit"
text of front text window options {search mode:grep, case sensitive:true}
end tell
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------