56 lines
1.5 KiB
Perl
56 lines
1.5 KiB
Perl
# opens files with mismatched snippets
|
|
|
|
use 5.12.0;
|
|
use File::Slurp;
|
|
use Cwd;
|
|
|
|
my ($pwd, $d, $textEditor, $browser) = (cwd(), "\\");
|
|
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
|
|
|
|
my ($udf) = "User_defaults.windows.txt";
|
|
if ($^O eq "linux") {$udf = "User_defaults.linux.txt"}
|
|
#elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
|
|
elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
|
|
|
|
open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!";
|
|
|
|
GetUserDefaults();
|
|
|
|
my $openString = "";
|
|
my $fileText = read_file("Temp${d}mismatched_snippets.html", binmode => 'utf8');
|
|
|
|
while ($fileText =~ /<p><b>(.*)<\/b><\/p>/g) {
|
|
unless ($openString =~ /$1/) {
|
|
$openString .= "$1 " unless $^O eq "linux";
|
|
}
|
|
}
|
|
|
|
if ($^O eq "linux") {$openString .= " &"}
|
|
|
|
say "\n\$textEditor \$openString:\n$textEditor $openString\n";
|
|
|
|
system ("$textEditor $openString");
|
|
|
|
sub GetUserDefaults {
|
|
open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!";
|
|
|
|
while (my $thisLine = <$defaults>) {
|
|
chomp $thisLine;
|
|
if ($thisLine =~ /^Text editor: (.*)$/) {
|
|
$textEditor = $1;
|
|
}
|
|
if ($thisLine =~ /^HTML browser: (.*)$/) {
|
|
$browser = $1;
|
|
}
|
|
}
|
|
|
|
if ($^O eq "darwin") {$textEditor = "open -a $textEditor"}
|
|
if ($^O eq "linux") {$textEditor = "$textEditor"}
|
|
if ($^O eq "MSWin32" || $^O eq "MSWin64") {$textEditor = "START \"\" \"$textEditor\""}
|
|
#say "\$textEditor: $textEditor";
|
|
die "No text editor found" if $textEditor eq "";
|
|
|
|
close $defaults;
|
|
}
|
|
|