On 7/6/05, Angerstein <[EMAIL PROTECTED]> wrote:
> 
> 
> for ($y = 1; $y <= $thrc; $y++){
>   $ary[$y] = threads->new(\&net1, $proto, $time);
>   $ary[$y]->detach;
> }
> 
> #or
> 
> @ary[1..150] = 0;
> foreach $element (@ary) {
>   $element = threads->new(\&net1, $proto, $time);
>   $element = detach;
> }
> 
> something short like or similar possible?
> 
> #this don“t work...
> @ary[1..150] = threads->new(\&net1, $proto, $time);
> @ary[1..150] = detach;
> 
> 

Angerstein,

Not sure what you mean by "short" here. Do you want the fewest lines
of code? Quickest execution? Least typing? there are a lot of
different kinds of "short" in programming.

I'm not quite sure what you're after with '@ary[1..150]'. This is
slice notation, and it probably doesn't do what you think it does. It
doesn't create an array with 150 elements. It takes elements 1-150 of
a prexisting array and does something with them. In a foreach loop,
saying 'foreach $element (@ary[1.150])' is equivalent to saying:

  foreach (1..150) {
    $element = @ary[$_];
  }

You're probably looking for something like the following:

  foreach (1..150) {
   @ary[$_] = threads->new(\&net1, $proto, $time);
   @ary[$_]->detatch;
  }

or even

  map [EMAIL PROTECTED] = threads->new(\&net1, $proto, $time); 
@ary[$_]->detach} 1..150;

I'm not sure, though, why you're bothring with the array if you're
just going to detatch. I think a little code would help us understand
better what it is you're trying to do.

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to