Perl: How can I echo perl vars to a logfile?

  • Thread starter Thread starter Bes
  • Start date Start date

Bes

Bes

Soldato
Joined
18 Oct 2002
Posts
7,318
Location
Melbourne
Hi

I have a perl script which writes 'nice' messages about what it is doing to the screen, and writes everything it does to a log (i.e. if tarring a file up, it writes the result of tar -cvf to the log file, etc).

Now the problem is I have some instances where I need to record perl variables in the log file, but I cannot get perl vars to be echoed to my script (I understand why this is I think), but how do I get around it? do I need to use a fork or something?

Also please tell me if I have taken a really dumb approach to writing my logfile :)

Here is the code:

How I am using Shell commands:

PHP:
use Shell qw (rpm tar echo);
$Shell::capture_stderr=1;

The problematic code:

PHP:
	print "\nWARNING!! REMOVAL FAILED! Please consult the following logfile to see what went wrong: $logFile. The script will now end.\n\n";
echo ("Uninstall Attempt Failed after the following command: rpm -e",$fullOldVersion,">>$logFile");
 
Back
Top Bottom