Barry Brevik wrote:

> I've got a thing that I think "ought to" work, but it does not. Most people 
> will probably think it's a waste of bandwidth, but it is driving me crazy.
> 
> As I understand it, in Perl, an array is really a vector, or a 1-dimensional 
> array. A multi-dimensional array can be hacked together. One way of doing 
> this is:
>  
>  @cnxns = ();
>  push @cnxns, [$a, $b, $c];
>  
> One way of accessing these elements is:
>  
>  print "$cnxns[0][0]\n"
>  print "$cnxns[0][1]\n"
>  print "$cnxns[0][2]\n"
>  
> ...which in this example with only one "row" in the array, would print the 
> values of $a, $b and $c.
> 
> Now, what I'm doing with this array is keeping track of network connections, 
> so I'm continually pulling a row off the bottom, servicing that connection, 
> then pushing it back onto the array (or not, if the connection is done), or 
> pushing new connections onto the array.
> 
> So if this works to load it:
>  
>  push @cnxns, [$a, $b, $c];
>  
> ...then to remove a row, I ought to be able to do something like this:
>  
>  ($a, $b, $c) = shift @cnxns;

Try: ($a, $b, $c) = @{shift @cnxns};

> I've tried every syntax variation I can think of, but it does not work. What 
> does work is:
>  
>  @row = shift @cnxns;
>  <access $a, $b and $c out of @row>
>  
> This seems like an annoyingly unnecessary piece of indirection to me. Does 
> anyone know a better way to do this? I hope I did not lose anyone with this 
> wordy post.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to