The following script print some characters.
how to print the characters to file ( f开发者_StackOverflow社区or example /var/tmp/file )
Yael
#!/usr/bin/perl 
@myNames = ('one', 'two', 'three' , 'A' , 'B' , 'C' , 'D' , 'E');
foreach (@myNames) {
print "$_\n";
} 
When you run the script, you can simply redirect the output to a file:
$ ./myscript.pl > /var/tmp/file
#!/usr/bin/perl 
@myNames = ('one', 'two', 'three' , 'A' , 'B' , 'C' , 'D' , 'E');
open(OUT,">","/var/tmp/file") or die "Could not open the output file: $!";
foreach (@myNames) {
print OUT "$_\n";
} 
close(OUT);
open(FILE, ">/var/tmp/file") || die "File not found";
print FILE @myNames;
close(FILE);
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use autodie qw(:all);
my @names = qw(one two three A B C D E);
{
    open my $fh, '>', '/var/tmp/file';
    foreach (@names) {
        print {$fh} "$_\n";
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论