Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Re: dynamically initializing variables with perl

by db2admin (Acolyte)
on Jan 08, 2003 at 05:18 UTC ( #225192=note: print w/replies, xml ) Need Help??

in reply to Re: dynamically initializing variables with perl
in thread dynamically initializing variables with perl

Thank you for your help. I tried the for loop but it doesn't initialize the variables $C1, $C2, $C3 even though the $msgcount is a value of 3. Just from looking at it, @C is never populated with any values so I would suppose @C would have to be set to the variables $C1, $C2 ... which I don't think will even be syntatically correct (i.e. @C = ($C1, $C2, ...)).

The map function does work when the checkbox is set to ON (when checked) but if the checkbox is not set, there is no value returned and the map function will not put anything into the array element for that checkbox. So if I were to delete message 1 and message 3, there is no way to correspond the array elements with a particular message since the array looks like this:

$C[0] = "ON"; $C[1] = "ON";
When in reality, it should look like:
$C[0] = "ON"; $C[1] = ""; $C[2] = "ON";
I am not aware of an option with the checkbox to have two settings. It's either ON or not ON (i.e. no value).

Thanks again.

David K.

Replies are listed 'Best First'.
Re: Re: Re: dynamically initializing variables with perl
by busunsl (Vicar) on Jan 08, 2003 at 07:03 UTC
    Try the following map (untested):
    my @C = map { param("C$_") || 'OFF' } 0..$msgcount - 1;
    It should give something like:
    $C[0] = "ON"; $C[1] = "OFF"; $C[2] = "ON";
      Wow! that works perfectly! Thank you very much.

      Best Regards,

      David K.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://225192]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2019-02-19 04:49 GMT
Find Nodes?
    Voting Booth?
    I use postfix dereferencing ...

    Results (101 votes). Check out past polls.