Subject: [LON-CAPA-dev] Re: [LON-CAPA-cvs] cvs: loncom /auth lonacc.pm

From: Guy Albertelli II <[email-masked]>
Date: Mon, 25 Feb 2002 16:52:42 -0500 (EST)

Hi Gerd,

> +                  $ENV{"form.$name"}.=','.$value;

This is lame, use a perl array.

   if ($ENV{"form.$name"}) {
	if (defined(@{ $ENV{"form.$name"} })) {
	    #already have multiple values
	    push(@{ $ENV{"form.$name"} },$value);
	} else {
	    #first multiple values, convert to array
	    my $first=$ENV{"form.$name"};
	    undef($ENV{"form.$name"});
	    push(@{ $ENV{"form.$name"} },$first,$value);
	}
    } else	{
	$ENV{"form.$name"}=$value;
    }

And you easily get acces

my @localarray=@{ $ENV{"form.name"} };

-- 
[email-masked]        BM: n^20 t20 z20 qS 
Guy Albertelli -7-9-8-  O-
    Having control over myself is nearly as good as having control
    over others.

---

From: Guy Albertelli II <[email-masked]>
Date: Mon, 25 Feb 2002 16:59:50 -0500 (EST)

Actually to be even closer to the request

this code will put a value in form.$name and a perl array will be in
form.$name[]

    if ($ENV{"form.$name"}) {
 	if (defined($ENV{'form.'.$name.'[]'} })) {
 	    #already have multiple values
 	    push(@{ $ENV{'form.'.$name.'[]'} },$value);
 	} else {
 	    #first multiple values, create an array
	    push(@{ $ENV{'form.'.$name.'[]'} },$ENV{"form.$name"},$value);
 	}
     } else {
 	$ENV{"form.$name"}=$value;
     }

my @localarray=@{ $ENV{'form.'$name.'[]'} };

-- 
[email-masked]        BM: n^20 t20 z20 qS 
Guy Albertelli -7-9-8-  O-
    I would love to but . . . it wouldn't be fair to the other Beautiful
    People.

---

From: Scott Harrison <[email-masked]>
Date: Mon, 25 Feb 2002 17:05:04 -0500

Minor bleep:
And if you want that perl array to be read/write, then
my $localarrayref=$ENV{'form.'.$name.'[]'};

Guy Albertelli II wrote:
> _______________________________________________
> LON-CAPA-dev mailing list
> [email-masked]
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev

-- 
Scott Harrison -- Graduate Student
Microbiology and Molecular Genetics
Mich. State. Univ., East Lansing, MI
[email-masked], 517-353-0998