473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Hash of Structs in a Package, is there an easier way?

Ok, so I'm working on a Perl proggy to convert Net.Data to JSP (gotta
love Perl.) I've got a Module that has a Class to store all relevant
information about a Net.Data user defined function that is read in. In
this class is a Hash of a Struct where the key is the variable name
and the Struct itself contains the variable type and value:

package ND2Parse::Function;

use Carp;
use Class::Struct;

struct Var => {
type => '$',
value => '$',
};

sub new
{
my $classname=shift;
my $functionname=shift;
my $self={
vars => {},
name => $functionname
};
bless($self,$classname);
return $self;
}

sub addvar
{
my $self=shift;
my $var=shift;
my $type=shift;
my $value=shift;
unless ($var)
{
carp "No var name passed in ->addvar(<var>,<type>,<value>)\n";
return 0;
}
${$self->{vars}}{$var}=Var->new();
${$self->{vars}}{$var}->type($type) if $type;
${$self->{vars}}{$var}->value($value) if $value;
return 1;
}
My question: Is there an easier/cleaner/more readable way to reference
and update the Struct other than what I'm doing:

${$self->{vars}}{$var}=Var->new();
${$self->{vars}}{$var}->type($type) if $type;
${$self->{vars}}{$var}->value($value) if $value;

Specifically, this portion seems rather unwieldy to me:

${$self->{vars}}{$var}
Any thoughts would be appreciated.

-Norm
Jul 19 '05 #1
1 4135
de***********@hotmail.com (Norman Ackroyd) wrote...
[...] this portion seems rather unwieldy to me:

${$self->{vars}}{$var}


Yeah, it usually written using the shorthand:

$self->{vars}{$var}

This newsgroup does not exist (see FAQ). Please do not start threads here.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Theodore Feldman | last post by:
If connection properties and global variables are set from an INI file, how can a DTS package be made truly portable? If the INI file pathname is hard-coded in the package, it must be edited...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
2
by: Ramon F Herrera | last post by:
Hello: Is there some C hash package out there? I am a big fan of the Berkeley DB, which has outstanding performance, but it is (I think) restricted to disk operations, while I would like to...
16
by: Michi Henning | last post by:
Below is a bit of code that creates a delegate. The delegate invokes a member function of a struct. The code compiles, but has surprising behavior: using System; namespace ConsoleApplication1...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
13
by: ababeel | last post by:
Hi I am using a calloc in a hash table program on an openvms system. The calloc is used to declare the hash table char **pHashes; pHashes = calloc(hash_size,sizeof(char *)); //hash_size = 101 ...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
24
by: Alexander Mahone | last post by:
Hello, I'm looking for an hash function to be used for an hash table that will contain structs of a certain kind. I've looked into Sourceforge.net, but so far I've found only hash functions for...
23
by: raylopez99 | last post by:
A quick sanity check, and I think I am correct, but just to make sure: if you have a bunch of objects that are very much like one another you can uniquely track them simply by using an ArrayList...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.