Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Perl - how to print to file
Name: satimis Date: November 12, 2004 at 20:06:22 Pacific OS: FC2 CPU/Ram: Athlon/512M
Comment:
Hi folks,
Perl ====
Instead of using following command printing output to a file;
$ perl AAA.pl > /pathto/name_of_file
is it possible adding "print file function" to the script
1) If YES Please advise how to make it.
2) Can I add following bash syntax to the script user=$(whoami); now=$(date +%Y.%m.%d.%R); File="/tmp/satimis/comparison_${user}_${now}.txt";
so that the printout file will carry name of creator, date and time, etc.
If possible please shed me some light to re-edit the script.
Name: FishMonger Date: November 13, 2004 at 13:23:53 Pacific
Reply:
#!/usr/bin/perl -w
use strict; use POSIX;
my $user = `whoami`;
my $now = strftime("%Y.%m.%d.%R", localtime(time));
my $file = "/tmp/satimis/comparison_${user}_${now}.txt";
open FILE, ">$file" or die "unable to open $file $!";
print FILE "this line sent/prints to your $file output file";
0
Response Number 2
Name: satimis Date: November 15, 2004 at 00:29:31 Pacific
Reply:
Hi FishMonger,
Tks for your advice.
I have tried severl hours on similar syntax without a breakthrough. I can only be allowed to print the "perl" output to a file OR to print it on terminal, but not both. Besides the username was missing on the file created only showing date and time.
Summary: I need to print a line or message to parallel port using C . After printing , the printer will stop at that line without scrolling. Please help ...
Summary: Hello, I'm having trouble creating files when iterating through a list using a "foreach" loop. i.e. I have a file, target.txt, that lists hostnames which contains: host1 host2 host3 I have a perl scr...
Summary: I think what you need is following. If you have a submit, you can call the perl script directly as FORM action as follows. <form method="POST" action="/cgi-bin/name_of_perl_scrip.pl"> &...