in reply to Re: writing to a file when using diamond operator
in thread writing to a file when using diamond operator

OK. Thanks Choroba, that makes sense.

However your code didn't work at first, and reading that you said

You need to open the file before you start the loop and close it after you finish reading it.

I tried

#!/usr/bin/perl use warnings; use strict; my $fichier_sortie = 'sortie.txt'; open my $sortie, '>', $fichier_sortie or die "Can't open $Fichiersor +tie: $!"; while (<>){ chomp; my $voir = $_; $voir =~ s/o/y/g; say {$sortie} $voir; } close $sortie;

And Yay !

Replies are listed 'Best First'.
Re^3: writing to a file when using diamond operator
by choroba (Cardinal) on May 03, 2024 at 15:34 UTC
    Of course, you're right. Sorry for the confusion.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Hm… With this construct I sense that I won't be able to forge the output file name from the content of the input file.

        You can always rename the file later.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]