Thanks for the reply.

Yes, I see I fat fingered the owner/some_owner variable.

It does compile on my system (if I omit use strict). I should add that
I'm running Perl 5.6.1 because some of the code I'm maintaining needs
this version.

Except for the last 7 lines where I'm trying to print out the field
elements, I pulled all the code from here:
http://www.unix.org.ua/orelly/perl/prog3/ch32_06.htm

Again, this compiles on my system if I omit use strict. If I add use
strict it instructs me that I need to
Global symbol "$store" requires explicit package name at
classexample.pl line 18.
Global symbol "$store" requires explicit package name at
classexample.pl line 19.
...

If I specify
$Shoppe::store = Shoppe->new();
and
$Shoppe::store->owner('Abdul Alhazred');
etc,
It passes the use strict specification, but it still fails at
print "owner: $Shoppe::store->owner()\n";
$some_owner =  $Shoppe::store->owner();
print "owner: $some_owner\n";

If I omit use strict it prints out the
Do I need to put the Class definition in a separate file and call it a
package, and then instruct my script to "use Shoppe"? That doesn't
seem right.

I'm pretty stumped, so thanks for your help. I think I'm pretty close.

Ed




On 4/10/06, Timothy Johnson <[EMAIL PROTECTED]> wrote:
>
> The code you provided can't be the example taken straight out of
> Programming Perl, because it doesn't compile.  Also, you've mistyped one
> of the variables.  You should always "use strict" and "use warnings" to
> avoid this kind of thing.
>
> Can't call method "name" on an undefined value at
> P:\Carnivore\Caymen\struct.pl line 24.
>
>
> -----Original Message-----
> From: Ed [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 10, 2006 11:57 AM
> To: beginners@perl.org
> Subject: Class::Struct: Can't access struct field elements
>
> I'm trying to use the Class::Struct to create some C-Like structs but
> I'm unable to dereference any array elements in the struct. I'm
> admittedly a Perl newbie trying to map my C programming experience
> into Perl so it's possible I'm "thinking in C" rathern than in Perl.
> I've referenced several texts and web references on the subject and
> get several ways to create a structure. In each case I'm unable to
> access any  elements in the structures once they are initialized.
>
>
> Here is an example taken straight out of Programming Perl (3rd ed) :
>
> <snip example>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


--
Ed

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to