in reply to Re^3: Read all the file path having text document
in thread Read all the file path having text document

No prototype, no warning.
Did you mean to convey that simply omitting the prototype from the predeclaration would suppress the warning?
>perl -wMstrict -le "sub S; S('foo'); sub S ($) { print $_[0], '-totyped subroutine' }; " foo-totyped subroutine
I was rather surprised to find that this worked! Can you point me to an explanation of why this works as it does?

In any event, I continue to agree it is best to avoid prototyping both in the OPed code and in general.

Replies are listed 'Best First'.
Re^5: Read all the file path having text document
by GrandFather (Saint) on Nov 30, 2008 at 01:02 UTC

    Actually, I'm surprised too. I really meant omit the prototype specification on the sub declaration:

    sub S {...}

    rather than:

    sub S ($) {...}

    In other words, don't use the prototype at all is the fix rather than using a forward declaration. If the sub isn't prototyped the forward declaration isn't required.

    A forward declaration with a different prototype than the actual declaration is an error reported by Perl, but not if the forward declaration is missing the prototype and the declaration has one - bizarre.


    Perl's payment curve coincides with its learning curve.
      ... - bizarre.

      Not at all. It's like the empty string matching any string. Once you've declared a prototype, there can be a mismatch, but not before.

        I don't understand. How is a forward declaration not a declaration?

        In both cases there is a mismatch between the forward declaration and the actual declaration. Not raising a warning in the case of a blank prototype in the forward declaration with a non-blank prototype in the actual declaration seems bizarre.


        Perl's payment curve coincides with its learning curve.