The following script print some characters.
how to print the characters to file ( for example /var/tmp/file )
Yael
#!/usr/bin/perl
@myNames = ('one', 'two', 'three' , 'A' , 'B' , 'C' , 'D' , 'E');
foreach (@myNames) {
print "$_\n";
}
The following script print some characters.
how to print the characters to file ( for example /var/tmp/file )
Yael
#!/usr/bin/perl
@myNames = ('one', 'two', 'three' , 'A' , 'B' , 'C' , 'D' , 'E');
foreach (@myNames) {
print "$_\n";
}
#!/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);
When you run the script, you can simply redirect the output to a file:
$ ./myscript.pl > /var/tmp/file
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";
}
}