Kailash wrote:
[snip]
Start each of your scripts with the following, it will
save you many hours of debugging:
#!/usr/bin/perl -w
use strict;
> $input = <STDIN> ;
Declaring your variables with 'my' will help you keep
track of their scope:
my $input = <STDIN>;
> # I process the input here
> # If the output from previous step is a single
> field, then call subroutine
> "test" or call sub routine "test1".
When you call the subroutines, pass in the variable
like this:
my $test_return = test($input);
I'll explain why I used $test_return below...
> sub test {
> # I would like to refer to the $input variable and
> variables declared in the
> main part
Inside the subroutines grab the variable like this:
my $input = shift;
Now do whatever you want to the variable.
If you want to pass something back from the
subroutine, end your subroutine like this:
return $input;
You don't have to use $input, you could pass anything
back. Now $test_return will hold whatever you
returned!
> }
HTH
=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/