Last active
February 4, 2017 07:23
-
-
Save secwang/f57dfe53cb4734e5abe58d42ae07e34b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8::all; | |
sub trim | |
{ | |
my $string = shift; | |
$string =~ s/^\s+//; | |
$string =~ s/\s+$//; | |
if(length($string)<1){ | |
return " "; | |
}else{ | |
return $string; | |
} | |
} | |
my $file = "a.txt"; | |
open my $in, "<:encoding(utf8)", $file or die "$file: $!"; | |
my @lines = <$in>; | |
close $in; | |
chomp @lines; | |
for my $line (@lines) { | |
my @a = split ',', $line; | |
my $b = shift @a; | |
$b = trim $b; | |
my $c = shift @a; | |
$c = trim $c; | |
my $out = <<_EOC_; | |
insert into item (item_desc,item_sku) values ("$b" , "$c");\n | |
_EOC_ | |
print $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment