Re: warning message

2003-04-02 Thread Wiggins d'Anconia


Christopher G Tantalo wrote:
Hello,
In a recent perl script I wrote, I have a procedure, read_config(),
which reads a
config file I have set up and sets a hash to what is in the file.  Now,
before you
mention it, I have stricts on and use the -w on the 1st line, and the
following
message appears.
main::read_config() called too early to check prototype at
./eleadtest.pl line 19.
What does this mean?  Code snippets of the procedure call, and the
procedure itself
are below.
In general Perl does not expect you to do strong typing of the arguments 
you pass into a subroutine so there is no need to use prototyping. 
Because you defined your subroutine using '()' Perl thinks you are 
trying to use prototyping, in which case you are calling the sub to 
early. So either you need to pre-declare the subroutine or simply not 
use a blank prototype... so instead of:

sub read_config()
{
> #blah blah blah
}
use:

sub read_config
{
# blah blah blah
}
For much more on subroutines and prototyping have a look at:

perldoc perlsub

In general the order of subroutine definition does not matter, or its 
placement in the file, with the exception of prototype'd functions which 
is what you ran into.

http://danconia.org

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


RE: warning message

2003-04-02 Thread Ken Lehman
looks like you tried to call the sub before you defined it, try putting a
definition just below all the use statements or just move the whole sub up
there
-Ken

-Original Message-
From: Christopher G Tantalo [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: warning message


Hello,
In a recent perl script I wrote, I have a procedure, read_config(),
which reads a
config file I have set up and sets a hash to what is in the file.  Now,
before you
mention it, I have stricts on and use the -w on the 1st line, and the
following
message appears.

main::read_config() called too early to check prototype at
./eleadtest.pl line 19.

What does this mean?  Code snippets of the procedure call, and the
procedure itself
are below.

#!/home/ctantalo/perl5/bin/perl -w
#
# Programmer: Chris Tantalo
#
# This program will call eleadsht.sqt and email the eleadsht.lis file
# based on the data in the dmg.eleadsht_parameters table
#
# $Version_id = "@(#) elead.pl [@@/main/dec02_corp_sup/1] >";

use strict;
use Mail::Sender;
use DBI;

# check to see if test machine(cad2) or production(sam)
my $node = `hostname`;
chomp $node;

our %hash;
read_config($node);


# the read_config procedure
sub read_config()
{
my $node = shift @_;
my $cfg_file = "";
my $key;
my $value;

$cfg_file = "/opt/appl/hrstmk/bin/elead.cfg" if($node eq "sam");

$cfg_file = "/usr/appl/cad/prod/hrstmk/bin/elead.cfg" if($node
eq "cad2");
open(CFG_FILE,"$cfg_file") ||die "cannot open $cfg_file for
reading:$!";

while()
{
next if($_ =~ /^#/);
($key,$value) = split(/=/,$_);
$hash{$key}=$value;
}

close(CFG_FILE);
}

TIA,
Chris

--
---
Just Your Friendly Neighborhood
_SPIDEY_
--
Anything added after this was added by my mail server and not me.
--


-
The information contained in this message may be privileged, confidential,
and protected from disclosure. If the reader of this message is not the
intended recipient, or any employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any
dissemination, distribution, or copying of this communication is strictly
prohibited. If you have received this communication in error, please notify
us immediately by replying to the message and deleting it from your
computer. 

Thank you. Paychex, Inc.


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



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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