[Jerusalem.pm] Variable length array to ref

Issac Goldstand margol at beamartyr.net
Mon Jan 24 06:24:01 PST 2005


No - that always returns a scalar, ala "join".
In the end, I decided to scratch the idea of allowing an array to be passed, 
so I just do my $elem=shift;  If someone really knows what they want, they 
can pass an arrayref...



----- Original Message ----- 
From: "Motke Keshet" <motkek at sintecmedia.com>
To: "Jerusalem Perl Mongers" <jerusalem at perl.org.il>
Sent: Monday, January 24, 2005 2:16 PM
Subject: RE: [Jerusalem.pm] Variable length array to ref


> 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
>
> _______________________________________________
> Jerusalem mailing list
> Jerusalem at perl.org.il
> http://perl.org.il/mailman/listinfo/jerusalem
> 




More information about the Jerusalem mailing list