Skip to content

Instantly share code, notes, and snippets.

@note103
Last active May 18, 2017 23:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save note103/a28597ca8824a4e8e83bc4f843184bf3 to your computer and use it in GitHub Desktop.
Save note103/a28597ca8824a4e8e83bc4f843184bf3 to your computer and use it in GitHub Desktop.
空白行が来るごとに数字をカウントアップしつつ挿入する
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
my @data = <DATA>;
my $num = 1; #<= 開始時点の数字を入れる
for my $data (@data) {
chomp $data;
if ($data =~ /\A\z/) {
say "# $num";
$num++;
}
else {
say $data;
}
}
__DATA__
# 以下に必要なデータを入れる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment