OT: Perl syntax Question

Devin Whalen devin-Gq53QDLGkWIleAitJ8REmdBPR1lH4CV8 at public.gmane.org
Mon Oct 24 15:09:04 UTC 2005


On Mon, 2005-10-24 at 10:52 -0400, Joseph Kubik wrote:
> What does the following mean?
> ($#{$reg->{'sale'}{'items'}} == -1)
> 
> As, in, What does $#{} really do?
> 
> Thanks,
> -Joseph-

Hey,

I think $reg->{'sale'}{'items'} returns an array reference.  You then
dereference the array with this:
{$reg->{'sale'}{'items'}} then the $# added to it causes the array to
return the highest index.  So if it returns -1 then the array is empty.
However, I think that this is deprecated so it would be better to use
scalar(@{$reg->{'sale'}{'items'}}) and test for 0.

Later


-- 
Devin Whalen
Programmer
Synaptic Vision Inc
Phone-(416) 539-0801
Fax- (416) 539-8280
543 Richmond Street West
Toronto, Ontario
Suite 223 M5V 1Y6
Box 105
Home-(416) 653-3982


Take back the Web with FireFox....a browser you can trust
www.getfirefox.com

   .-.
   /v\    L   I   N   U   X
  // \\  
 /(   )\
  ^^-^^   

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list