I strongly suggest you stop using subroutine prototypes. The way you have used them above is completely misleading. You have several things you need to learn about Perl but mostly all you need to learn about Perl's subroutine prototypes at this point is "don't use them". (:

Now, to questions you didn't ask... Perl subroutines get passed a list of scalar "values" (I put "values" in quotes for reasons that I'll won't explain because they don't affect the problem you are having right now). So if you have

my @sorted= sort qw(this list isn't sorted yet); my $num= 3; display_results( @sorted, $num );
then the display_results subroutine gets passed the following list of values: ("isn't","list","sorted","this","yet",3) You'll note that there is no special mark between "yet" and 3. So, inside the subroutine, @_ will be set to that list. $_ will be set to whatever it was set to before as $_ isn't used for passing arguments to subroutines.

So if you want to pass both some scalars and an array/list to a subroutine, then you need to make the array/list as the last argument:

display_results( $num, @sorted ); sub display_results { my( $num, @sorted )= @_;
I suggest you do some reading in any of the many fine sources of documentation on this stuff. (:

        - tye (but my friends call me "Tye")

In reply to (tye)Re: calling sub routine problem? by tye
in thread calling sub routine problem? by slok

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.