This is to provide you with a fairly basic example. Lets say you have a sub routine that adds two number together and gives you the result of that operation. You would pass two numbers (your parameters, or arguements as they are called), the sub would then add them and return the result to your main section.
#!/usr/bin/perl -w use strict; my $first_number=5; my $second_number=1; my $result=Add($first_number,$second_number); print"And the result is $result.\n"; sub Add{ my($x,$y)=shift; my $result=$x+$y; return $result; }
The reason you use sub-routines(also known as functions) is to avoid typing code over and over again. This way, if you have to perform a specific operation over and over again on constantly changing data, you can simply send the data to the subroutine, it will do the operation on it, and return the result to you.

TStanley
--------
There's an infinite number of monkeys outside who want to talk to us
about this script for Hamlet they've worked out
-- Douglas Adams/Hitchhiker's Guide to the Galaxy

In reply to Re: Use of perl by TStanley
in thread What is the purpose of subroutine parameters? by chip1232

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.