Skip to content

Instantly share code, notes, and snippets.

@uasi
Created August 20, 2013 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uasi/6277537 to your computer and use it in GitHub Desktop.
Save uasi/6277537 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.014;
use warnings;
use Getopt::Long;
GetOptions(
'dry-run|n' => \my $opt_dry_run,
'force|f' => \my $opt_force,
);
die "Neither -n nor -f given\n" unless $opt_dry_run || $opt_force;
my $replace = ($opt_dry_run && $opt_force) ? undef
: $opt_force ? 1
: undef;
do {
local $^I = $replace;
my $jisyo_file = shift || '';
die "Could not open SKK-JISYO '$jisyo_file'\n" unless -f $jisyo_file;
@ARGV = $jisyo_file;
while (<>) {
if ($replace) {
print unless m|//$|;
}
else {
print "Would remove $_" if m|//$|;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment