Can't use global FILEHANDLEs?

From: Teamsolco (teamsolco_at_teamdelsol.com)
Date: 01/30/04


To: "Perl Beginners List" <beginners@perl.org>
Date: Fri, 30 Jan 2004 15:01:59 -0700

To start, let me say this:
1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed"
2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as reference.
3) I have searched with Google for several key words related to my problem, but the mass of junk I get back is not
helpful.
4) The application source is roughly 450 lines long, and the FAQ for this list asks users not to mass-post such things,
otherwise I'd post it here en-masse for help.

And, most importantly:
A) I didn't write the application I'm working on, I extended it (to a great deal) using the same programming style as
the original author (and other programmers before me), except that I've been "cleaning up" the old code a great deal.
B) I understand this application is quite old, probably written in Perl 4 days, and shows no OO influence (was
originally written as a down-and-dirty utility script).

That said, please do not assume that I am incompetent; I'm just frustrated. I've been programming for more than 20
years, just not with Perl (no, I'm not a VB "programmer" -- my experience is primarilly C).

Now then, I've opened a can of worms by adding "use strict" and "use warnings" to the source. Keep in mind that this
application was running JUST FINE before doing this. I'm only trying to 'modernize' this old code. Having started with
a couple screen-fulls of resulting errors, I'm down to just one: "Can't use an undefined value as a symbol
reference..." The partucular block that causes this error is:

sub close_fifo {
 close($hndFIFO);
}

It's related open sub is:

sub open_fifo {
 close_fifo();

 # Make sure the $hndFIFO file is a pipe.
 unless (-p $path_fifo) {
  unlink($path_fifo);
  system("mkfifo $path_fifo") or die("Can't mkfifo $path_fifo: $!");
  chmod(0600, $path_fifo);
 }

 # Open the $hndFIFO stream.
 open($hndFIFO, "< $path_fifo") or die("Can't open $path_fifo: $!");
}

and, at the top of this source, I have declared $hndFIFO (along with the log file handle) using our as in:

our ($hndLOG, $hndFIFO);

Before applying the aforementioned pragmas, the FIFO handle was simply, FIFO. There was no "our" declaration, at all,
and the variable/handle name was not prefixed with the scalar $ indicator. Everything worked at that time... Clearly,
I'm trying to delcare the FIFO (and log file) file handles as global to the application so that I can access them freely
in several other subs. What do I need to do to satisfy the strict pragma, while accomplishing my goal?

Thanks!!

- William Kimball
  "Programming is an art-form that fights back!"



Relevant Pages

  • Re: Emailing a Report -- SendObject parameters
    ... I began to read your access basics for programming, ... My next question and problem is regarding the Private Sub Command Click ... pSQL "Daily Reminders All Teams Report" ... 'loop through the Recordset until the end ...
    (microsoft.public.access.modulesdaovba)
  • Re: Emailing a Report -- balance Sub/End Sub, compile
    ... "I began to read your access basics for programming, ... Private Sub Command18_Click ... 'pSQL -- defines the recordset to open ... pSQL "Daily Reminders All Teams Report" ...
    (microsoft.public.access.modulesdaovba)
  • Re: Opinion from Doug Robbins and Peter Hewett Requested
    ... but I have no idea how to "output" any other data that the logit class ... >> Public Sub DoSomething() ... >> ' Write something to the log file ... >>> Public Property Let Path ...
    (microsoft.public.word.vba.general)
  • Re: Massive failed FTP attempts.
    ... made it a little more generic so that it could monitor any log file. ... To run as a daemon and monitor proftpd, sending lockout notifications to ... sub prune_old_entries ... my $line = shift; ...
    (Security-Basics)
  • Re: Sending debugging messages to a second document.
    ... Private mboolTimeStamp As Boolean ... Public Sub Output ... ' Delete the current log file if it exists ... Public Property Let Path ...
    (microsoft.public.word.vba.general)