2
我目前尝试添加语音标记到起始和线,我有从CSV文件的编辑和当前存储在数组中的端部;我目前正在尝试使用push和unshift。Push和不印字problems-的Perl
use warnings;
use Text::CSV;
use Data::Dumper;
use constant debug => 0;
use Text::CSV;
print "Running CSV editor......\n";
#my $csv = Text::CSV->new({ sep_char => ',' });
my $file = $ARGV[0] or die "Need to get CSV file on the command line\n";
my $fileextension = substr($file, -4);
#If the file is a CSV file then read in the file.
if ($fileextension =~ m/csv/i)
{
print "Reading and formating: $ARGV[0] \n";
open(my $data, '<', $file) or die "Could not open '$file' $!\n";
my @fields;
while (my $line = <$data>)
{
#Clears the white space at the end of the line.
chomp $line;
#Splits the line up and removes the <br />.
my @lines = split qr{<br\s?/>}, $line;
#Removes the control character.
shift (@lines);
print "\n";
print $_,$/ for @lines;
push (@lines, "\"");
unshift (@lines, "\"");
当我尝试使用最后两行时,它不会在开始和结束时添加任何内容。
你为什么不使用文字:: CSV引号将在那里?你怎么知道后两行不做任何事情?这些行之后的数据你什么都不做。为什么你有一个名为'@ lines'(复数)的变量,其中包含单行的分割部分? – Quentin 2012-08-03 14:18:25
你需要一个连接才能把它放回到一个单一的字符串 – stark 2012-08-03 14:23:53
请发布实际的代码和一小部分输入。 – 2012-08-03 14:28:09