Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Class::Struct array assignment and access

Reply
Thread Tools

Class::Struct array assignment and access

 
 
nelson331
Guest
Posts: n/a
 
      04-29-2006
I want to access a structure within a structure. Below is what I had
in mind. Please help.

#!/perl/bin/perl
use Class::Struct;

struct Step => {
number => '$',
otherstuff => '$',
};

struct Block => {
number => '$',
steps => '@', #should be an array of "Step"s
};

my $step1 = Step->new();
$step1->number(1);

my $step2 = Step->new();
$step2->number(2);

#will eventually be in side a loop @stepArray = (@stepArray,
$tempStep);
@stepArray = ($step1, $step2);

my $block1 = Block->new();
$block1->number(1);
$block1->steps(@stepArray);

@blockArray = (@blockArray, $block1);

#would then like to access the Steps within the Blocks
foreach $tempBlock (@blockArray) {
foreach $tempStep ($tempBlock->steps) {
print $tempStep->number;
}
}

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      04-29-2006
"nelson331" <(E-Mail Removed)> wrote in news:1146335481.061030.164470
@i40g2000cwc.googlegroups.com:

> I want to access a structure within a structure. Below is what I had
> in mind. Please help.


I don't understand what you need help with.

> #!/perl/bin/perl


This is an odd shebang line for sure.

> @blockArray = (@blockArray, $block1);


There is no mention of @blockArray before this line.

Make sure to put

use strict;
use warnings;

in your script, and tell us, please, what is your question?

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html

 
Reply With Quote
 
 
 
 
nelson331
Guest
Posts: n/a
 
      04-29-2006
The shebang line is for windows.
The @blockArray was only for example.

Basically, I want to access a structure within a structure. I need to
be able to store and retrieve.

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      04-29-2006
"nelson331" <(E-Mail Removed)> wrote in news:1146344317.750874.232720
@i39g2000cwa.googlegroups.com:

[ Please read the posting guidelines for this group, and quote some
context when you reply ]

> The shebang line is for windows.


You don't need a shebang line for Windows.

> The @blockArray was only for example.
>
> Basically, I want to access a structure within a structure. I need to
> be able to store and retrieve.


Please don't post pseudo-code. Post a short but complete script which
others can run (as described in the posting guidelines) to show what you
have tried and what does not work.

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html

 
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
Assigning an array to another array using C's assignment operator Myth__Buster C Programming 13 02-26-2013 04:29 PM
Assigning an array to another array using C's assignment operator Myth__Buster C Programming 1 02-01-2013 12:27 AM
Assigning an array to another array using C's assignment operator Myth__Buster C Programming 0 02-01-2013 12:05 AM
Assignment operator self-assignment check Chris C++ 34 09-26-2006 04:26 AM
Augument assignment versus regular assignment nagy Python 36 07-20-2006 07:24 PM



Advertisments