in reply to subroutine..help

You're not making any use of the arguments in your subroutine, so $a, $b are both zero.

You shouldn't rely on global variables to convey information in and out of a subroutine. Here is how your code might be better written,

sub coor { my ($c, $d) = @_; return ( $c + 109, $d + 5 ); } my @y1_opp = coor( 1, 5); print "@y1_opp\n";
I've renamed $a and $b since they are sacred to sort in Perl.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: subroutine..help
by hmerrill (Friar) on Oct 29, 2004 at 12:01 UTC
    Just personal preference here, but I prefer to use "shift" instead of picking off arguments from @_, like this:
    sub coor { my $c = shift; # get 1st argument my $d = shift; # get 2nd argument return ( $c + 109, $d + 5 ); }
    And, the OP should use "use strict;" and either "-w" on the first perl line or "use warnings;".