Perl: depois de chomping uma string, ela não imprime o valor da string
No momento, estou tentando escrever um script perl que lê em um arquivo e grava em outro. Atualmente, o problema que estou enfrentando é a remoção de novos caracteres de linha de linhas analisadas.
BetteDavisFilms.txt
1.
Wicked Stepmother (1989) as Miranda
A couple comes home from vacation to find that their grandfather has …
2.
Directed By William Wyler (1988) as Herself
During the Golden Age of Hollywood, William Wyler was one of the …
3.
Whales of August, The (1987) as Libby Strong
Drama revolving around five unusual elderly characters, two of whom …
Por fim, estou tentando colocá-lo em um formato como este
1,Wicked Stepmother ,1989, as Miranda,A couple comes home from vacation to …
2,Directed By William Wyler ,1988, as Herself,During the Golden Age of …
3,"Whales of August, The ",1987, as Libby Strong,Drama revolving around five…
remove com êxito os reconhecimentos para cada número, mas quero remover o \ n e substituir o "." com um ",". Infelizmente, a função chomp destrói ou oculta os dados de alguma forma. Quando imprimo após chomping $ row, nada mostra ... O que devo fazer para corrigir isso?
#!bin/usr/perl
use strict;
use warnings;
my $file = "BetteDavisFilms";
my @stack = ();
open (my $in , '<', "$file.txt" ) or die "Could not open to read \n ";
open (my $out , '>', "out.txt" ) or die "Could not out to file \n";
my @array = <$in>;
sub readandparse() {
for(my $i = 0 ; $i < scalar(@array); $i++) {
my $row = $array[$i];
if($row =~ m/\d[.]/) {
parseFirstRow($row);
}
}
}
sub parseFirstRow() {
my $rowOne = shift;
print $rowOne; ####prints a number
chomp($rowOne);
print $rowOne; ###prints nothing
#$rowOne =~ s/./,/;
}
#call to run program
readandparse();