送给你一个函数Convert():
#!/usr/bin/perl use strict; my $tmp1='"asd ,asd", "123,345.78", "(12,345.67)","34"'; my $tmp2 = Convert($tmp1); print "$tmp2\n"; exit(0); sub Convert { my $intext = shift; return join(",", map { if($_ =~ /[a-z]/) #chars { $_ = '"'.$_.'"' } else #digits { if( $_ =~ /^\(.+\)/ ) { $_ =~ s/[\(\)]//g; $_ = '-'.$_; } $_ =~ s/,//g; } $_; } grep(/./, split(/"\s*,*\s*"*/, $tmp1))); }