SPUG: problem in printing the struct member variables

Jafaar Nyang'oro seppy at mail.TANZATECH.COM
Wed Aug 4 18:31:19 CDT 1999


Hi
I am trying to create a table-like structure, I am successful
in creating the structure, but when I try to print the value 
stored in the structure member it's printing the address instead
of the value it contains.
can you pl. tell me why is it failing to print the values ?

#!/usr/local/bin/perl

use Class::Struct;
#use diagnostics;

struct ( Table => [
        header => '@',
        comments => '@',
        rows => '@',

] );

my $obj = new Table;

open (INPUT_FILE, "<test.dat") || die "Failed to open INPUT_FILE\n";
while(<INPUT_FILE>)
{
        $index=0;

        if($_=~/^HEADER/)
        {
                print "entered if statement \n";
                #$obj->header($_);
                $some_name =  $_;
                $obj->header($_);
                print "$some_name\n";
                printf "using instance %s \n", $obj->header;
        }
        elsif($_=~/^#/)
        {
                print "entered comment line \n";
                $some_comment = $_;
                $obj->comments($_);
                print "SOME COMMENT ---- $some_comment \n";
        }
        else
        {
                print "entered rows \n";
                $some_rows =  $_;
                $obj->rows(\@_);
                print "Some Rows ---- $some_rows\n";
                printf "---> %s\n", $obj->rows;
        }
}


And the test.dat contains

#This file was created on 08/04/99
HEADER  Name    EmpID   Manager
Seppy   1       David
Stella  2       David
Siva    3       David


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list