Teamsolco wrote:
> 
> 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.

If you could post it somewhere where it can be downloaded, that would be
best.

> 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.

BTDT ... Loads 'O Fun.

> 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..."

Perl's warning/error messages are described in the perldiag.pod
document.

perldoc perldiag
[snip]
       Can't use an undefined value as %s reference
           (F) A value used as either a hard reference or a sym­
           bolic reference must be a defined value.  This helps
           to delurk some insidious errors.

You can have perl print out these messages automatically if you add the
line "use diagnostics" to your program.


> 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);

You should check the return from unlink.

    unlink $path_fifo or die "Cannot unlink $path_fifo: $!";


>   system("mkfifo $path_fifo") or die("Can't mkfifo $path_fifo: $!");

system() returns true on failure and false on success so using 'or' will
cause it to die on success and the $! variable will not contain any
useful information as system() doesn't set $!.  The system() entry in
perlfunc.pod describes this behaviour and the correct way to use
system().

perldoc -f system

But you could use the POSIX::mkfifo() instead.

use POSIX qw( mkfifo );

mkfifo $path_fifo or die "Can't mkfifo $path_fifo: $!";


>   chmod(0600, $path_fifo);

You should check the return from chmod.

    chmod 0600, $path_fifo or die "Cannot chmod $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);

Why use 'our' and not 'my'?  Why use scalars and not filehandles?


> 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?

It is not clear from the snippet you provided what the problem is. 
Sometimes errors are reported for the wrong line number.  I know from
experience that converting Perl4 code to Perl5 can at times be quite
challenging.  It would help a lot to see the original Perl4 code.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to