Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: why does location of function matter?

by BrowserUk (Patriarch)
on Jun 01, 2015 at 22:09 UTC ( [id://1128661]=note: print w/replies, xml ) Need Help??


in reply to why does location of function matter?

I don't have any prototypes defined and I'm really at a loss as to why it should matter where the function is. Any ideas?

You don't show us the critical piece of information, namely the function definition; but from the error message, I'd guess that your function looks something like this:

sub PostValidate() { #...............^^ # stuff here. ... }

Which defines a function that takes no arguments.

If that is seen before the function is called; it will complain that you passed too many arguments.

If it is not seen until after the function call is compiled, then the prototype is too late to be applied.

Does that fit your code?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: why does location of function matter?
by Anonymous Monk on Jun 01, 2015 at 22:14 UTC

    With warnings enabled that would cause a "X called too early to check prototype" warning.

Re^2: why does location of function matter?
by smartyollie (Novice) on Jun 01, 2015 at 22:35 UTC
    ##########################
    sub PostValidate() {
    ##########################
    my ($file) = @_;
    my $cmd = "wc -l $file";
    {more stuff}

      That should be written as:

      sub PostValidate { ... }

      As you have it declared, sub PostValidate does declare a prototype. An empty prototype means no args may be passed (assuming Perl sees the subroutine is declared before its first use, as you've discovered).


      Dave

      I don't have any prototypes defined

      sub PostValidate() {

      An empty prototype () is still a prototype.

      You should always Use strict and warnings.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128661]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found