Hi.
Still struggling with some basic things here.
If I do
while (<>){ chomp; my $voir = $_; $voir =~ s/o/"y"/gem; say $voir; }
On a multiline text file, I do get the expected result with the input file modified as desired.
However, if I try this to write resulting lines to a specific file
while (<>){ chomp; my $voir = $_; $voir =~ s/o/"y"/gem; my $Fichiersortie = 'sortie.txt'; open my $sortie, ">", $Fichiersortie or die "Can't open $Fichier +sortie: $!"; say $sortie $voir; close($sortie); }
All I get is a one-line file with the last line (modified) only.
I feel that I don't understand some very basic diamond principle here, something to do with this elusive part of the PRINT doc maybe :
To use FILEHANDLE without a LIST to print the contents of $_ to it, you must use a real filehandle like FH , not an indirect one like $fh .Could a holy one enlighten me please ?
In reply to writing to a file when using diamond operator by paschacroutt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |