#!/usr/local/bin/perl -w
use strict;
local *FH1;
local *FH2;
my $source;
my $target;
foreach $source (@ARGV) {
$target = "converted_" . $source;
open(FH1, "<", $source) || die "Open $source was failed.\n";
open(FH2, ">", $target) || die "Create $target was failed.\n";
while () {
$_ =~ s/^,[^"]*(?=\n)$/$&"/;
print(FH2 $_);
}
close(FH1) || die "Close $source was failed.\n";
close(FH2) || die "Close $target was failed.\n";
}
exit 0;
use strict;
local *FH1;
local *FH2;
my $source;
my $target;
foreach $source (@ARGV) {
$target = "converted_" . $source;
open(FH1, "<", $source) || die "Open $source was failed.\n";
open(FH2, ">", $target) || die "Create $target was failed.\n";
while (
$_ =~ s/^,[^"]*(?=\n)$/$&"/;
print(FH2 $_);
}
close(FH1) || die "Close $source was failed.\n";
close(FH2) || die "Close $target was failed.\n";
}
exit 0;
댓글
perl -p -e "s/^,(.+?)([^\"])$/,\1\2\"/g" test.dat
windows 환경에서는 "표를 사용해야함