Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > C struct equivalent

Reply
Thread Tools

C struct equivalent

 
 
Martin Johansen
Guest
Posts: n/a
 
      01-24-2005
Hello

I need to use structure like:

struct{
int x;
array *a;
int z;
}s;

Can I access some structure in perl using e.g. s.a or similar

Thanks.


 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      01-24-2005
"Martin Johansen" <(E-Mail Removed)> wrote:
> Hello
>
> I need to use structure like:
>
> struct{
> int x;
> array *a;
> int z;
> }s;
>
> Can I access some structure in perl using e.g. s.a or similar


perldoc -q struct

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      01-25-2005
Martin Johansen <(E-Mail Removed)> wrote:

> Subject: C struct equivalent



perldoc -q struct

How can I make the Perl equivalent of a C structure/C++ class/hash or
array of hashes or arrays?

How do I declare/create a structure?


You are expected to check the Perl FAQ *before* posting to
the Perl newsgroup.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      01-25-2005
Martin Johansen wrote:

> Hello
>
> I need to use structure like:
>
> struct{
> int x;
> array *a;
> int z;
> }s;
>
> Can I access some structure in perl using e.g. s.a or similar
>
> Thanks.


Normal way to do this is with a hash:

my %s = (
x => 0,
a => [],
z => 0
);

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
Reply With Quote
 
Martin Johansen
Guest
Posts: n/a
 
      01-25-2005
Thanks

That solved the problem.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
struct equivalent with rails-y keyword args hash? Giles Bowkett Ruby 9 01-10-2008 08:48 AM
Is struct() equivalent to ZeroMemory() ? Jim Langston C++ 4 08-28-2007 04:12 AM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM
implementing a templated struct within a templated struct RA Scheltema C++ 3 01-06-2004 11:25 AM



Advertisments