我目前正在尝试将语音标记添加到我从 CSV 文件编辑并当前存储在数组中的行的开头和结尾;我目前正在尝试使用 push 和 unshift。
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, "\"");
当我尝试使用最后两行时,它不会在开头和结尾添加任何内容。