> From: Mallik [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 3 March 2004 1:00 AM > To: Perl Beginners > Subject: Passing array as First argument > Importance: High > > Dear Friends, > > I need to pass 3 parameters to a subroutine, in which the > first parameter is an array and the last two parameters > are strings. > > @abc = qw(1 2 3); > $x = 4; > $y = 5; > > testsub(@abc, $x, $y);
Since you marked this message HIGH IMPORTANCE, and sent it twice to make sure, I just HAVE to throw in my 2c. You can do one of two things. (1) Change the first parameter to an array reference (2) Put 'x' and 'y' BEFORE the array. Read the perlsub man page Avoid the prototypes. > > sub testsub(@$$) > { > (@abc, $x, $y) = @_; > print "Array @abc\n"; > print "x $x\n"; > print "y $y\n"; > } > > The output of the above code is > Array 1 2 3 4 5 > x > y > > As seen above, all the parameters are assigned to the array. > > So, how can get the values into x and y. > > Thanks in advance. > Mallik. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>