Scott, Joshua wrote:

What do I need to do in order to use a filehandle that was opened earlier in
a program within a subroutine?  I've included an example of the code I have
that is not doing what I would like.  Basically, I never get any output to
the file.  If I change it so that it doesn't use the subroutine when writing
to the filehandle, it works fine.  What am I doing wrong?


This is a buffering issue



Thank you in advance for any help you can provide.


Joshua Scott
Security Architect, CISSP
Jacobs Engineering

EXAMPLE CODE
#########################################


Always use strict and use warnings or the -w flag when developing code


$logfile = "/var/log/logfile";
Open(FILE,">>$logfile");


check if open succeeded open (FILE, ">>$logfile") or die "failed to open $logfile for writing, $!\n";

Add this piece of code and check
select (FILE);
local $| = 1;

perldoc -q flush
perldoc -f select #1 argument form of select
perldoc -f print


While(1) { &event_log("Logging some data"); sleep 60; };

Sub event_log {
  print FILE "LOG MESSAGE: $_[0]\n";
};
#########################################

==============================================================================
NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing,
copying or distribution of, or reliance on this message by unintended
recipients is strictly prohibited. If you have received this message in
error, please notify us immediately by replying to the message and deleting
it from your computer.


==============================================================================






-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to