[Jerusalem.pm] Variable length array to ref

Motke Keshet motkek at sintecmedia.com
Mon Jan 24 04:16:19 PST 2005


Hi Issak,

Sorry for the delay - hope it's not relevant anymore..
Anyway,
I probably don't understand the question, since it looks quite simple.

Look at the following program:


@args = (1,2,3,4,5,6);
stam (@args);



sub stam {
   $x1 = shift;
   $x2 = shift;
   @lst = @_;
   $str = join ",", @lst;
   print "$str\n";
   $x = 1;
	
	
}

@lst gets the rest of args.
If you do it in scalar context - you get the number.


was this your question or did I get it totally wrong ?


   Motke

-----Original Message-----
From: jerusalem-bounces at perl.org.il
[mailto:jerusalem-bounces at perl.org.il] On Behalf Of Issac Goldstand
Sent: Wednesday, January 19, 2005 2:15 PM
To: Jerusalem Perl Mongers
Cc: perl at perl.org.il
Subject: [Jerusalem.pm] Variable length array to ref

Hi mongers,
  I've got a function that takes a variable number of parameters.  After
I 
parse a few (by shift()ing them), I want to assign what's left to a 
variable.  Currently, I do:  $self->{uc($param)}=@_;

I could swear that this used to work.  But now, it doesn't.  It always
sees 
a scalar context so returns #@_ (the number of elements in @_)  How can
I 
get whatever happens to be left in @_?  (i feel silly asking this - I
feel 
there's a simple solution that i'm probably overlooking since I've
confused 
myself too much with the code around this)

Thanks!
  Yitzchak 

_______________________________________________
Jerusalem mailing list
Jerusalem at perl.org.il
http://perl.org.il/mailman/listinfo/jerusalem




More information about the Jerusalem mailing list