in reply to What is the purpose of subroutine parameters?

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

Replies are listed 'Best First'.
Re: Re: Use of perl
by Anonymous Monk on Sep 17, 2001 at 09:39 UTC
    You mean my($x,$y)=(shift,shift);