Skip to content

Instantly share code, notes, and snippets.

@note103
Created December 28, 2013 10:20
Show Gist options
  • Select an option

  • Save note103/8158039 to your computer and use it in GitHub Desktop.

Select an option

Save note103/8158039 to your computer and use it in GitHub Desktop.
タグ整理のためにスクエアブラケット外すためのもの
#!/usr/bin/env perl
use strict;
use warnings;
open (FILE, 'buffer.txt');
my @lines = <FILE>;
for my $line (@lines) {
if ($line =~ /\[(.+)\]\[(.+)\]/) {
print "$1, $2\n";
} elsif ($line =~ /\[(.+)\]/) {
print "$1\n";
} else {
print "$line";
}
}
@note103
Copy link
Author

note103 commented Dec 28, 2013

なんでelse以外では\nが必要だったのか自分で分からなかったけど、読み込んだファイルがすでに改行込みのデータだったから、ママで出力する最後だけ改行不要だったのか

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment