I think you have mis-understood the comment about prototypes. I suspect that you probably didn't even know that you were declaring a prototype.

The simple explanation is: when you define a sub X, do not put parens, () after the name.
That's it.
sub X(){} means something very different than just sub X{}.
I would go as far as to say that you never have to, and normally should not put any (....stuff...) after the sub's name.

-What you have done with shift is 100% correct.
-Maybe chomp() is not necessary, but it doesn't "hurt".
-A more important point for me is to indent the lines within the subroutine by either 3 or 4 spaces.

"Prototype failure" example:

#!/usr/bin/perl -w use strict; # This sequence works, although with a warning... # because Perl hasn't yet seen subroutine X. X("xyz"); sub X() # this means that subroutine X cannot # be called with any arugment at all. # sub X(); #is ok, # sub X("abc"); #is not ok. { my $input = shift; print "$input\n"; } #this would fail to produce a result - program fails to compile # X("abc"); # because now that subroutine X() has been seen, it is understood # that no arguments can be passed to it. __END__ prints: main::X() called too early to check prototype at C:\TEMP\prototypes.pl + line 4. xyz

In reply to Re^3: Regex with multiple pattern omissions by Marshall
in thread Regex with multiple pattern omissions by jhoop

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.