Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Perl - how to print to file

Original Message
Name: satimis
Date: November 12, 2004 at 20:06:22 Pacific
Subject: Perl - how to print to file
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.

TIA

B.R.
satimis


Report Offensive Message For Removal


Response Number 1
Name: FishMonger
Date: November 13, 2004 at 13:23:53 Pacific
Subject: Perl - how to print to file
Reply: (edit)
#!/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";


Report Offensive Follow Up For Removal

Response Number 2
Name: satimis
Date: November 15, 2004 at 00:29:31 Pacific
Subject: Perl - how to print to file
Reply: (edit)
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.

Any further advice which I have to observe. TIA

B.R.
satimis


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Perl - how to print to file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC