You need to get mail and pack it in txt files. I have a variable $_[0] , which stores the serial number of the letter. Why

 open(FILE "> $_[0]mail.txt") 

does not work? The name is obtained by mail.txt. How to do right?

    5 answers 5

    You are using an outdated way of working with files. Much better so

     open my $fh, '>', $filename or die "$!: $filename"; print $fh $mail_body; close $fh 

    That's where the $ [0] variable appears, assign it to a normal variable with a normal visibility range my $ var = $ [0] and then where you need to open (FILE '>'. $ Var.'mail.txt ')

      And write this line before creating the file and check if you have something in this variable: print $ _ [0]; exit;

        A better assignment is to do this:

         my $filename = shift; 

        Looks better :-)

          open (FILE "> $ {_ [0]} mail.txt")