Perl: Excel でブロックコピーして貼り付けたテキストを処理する2005年11月18日 12時41分37秒

# Excel でブロックコピーして貼り付けたテキストを読み込んで何とかする
# プログラムのサンプル

use strict;

our @sheet = ();
my $line = [];
my $quote;

while (<>){
	chomp;
	my @cells = split /\t/;
	if ($quote){
		my $cell = shift @cells;
		my $text = $cell;
		$text =~ s!"+!'"' x int(length($&) / 2)!eg;
		$line->[$#$line] .= "\n$text";
		$cell =~ s/""//;
		$cell =~ /"$/	or next;
		undef $quote;
	}
	if (@cells){
		my $cell = pop @cells;
		push @$line, @cells;
		my $text = $cell;
		$cell =~ s/""//;
		if ($cell =~ /^"/ && scalar($cell =~ /"/g) % 2){
			$quote = 1;
			$text =~ s!"+!'"' x int(length($&) / 2)!eg;
		}
		push @$line, $text;
	}
}
continue {
	push(@sheet, $line), $line = []	unless $quote;
}

for my $line (@sheet){
	# 何とかする処理をここに記述...
}

っていうか、クラス化しないまでも、せめて関数化しろよ>ヲレwww

マンション、ホテル 21 棟が書類上で耐震強度偽造2005年11月18日 18時34分31秒

こういうことやってっからマンション買う気が失せるんだよ。始めっからないけどな