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

No prototype, no warning.


Perl's payment curve coincides with its learning curve.
  • Comment on Re^3: Read all the file path having text document

Replies are listed 'Best First'.
Re^4: Read all the file path having text document
by AnomalousMonk (Archbishop) on Nov 30, 2008 at 00:51 UTC
    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.

      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.