develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #20765] bug in documentation of Class::struct

Thread Next
From:
perlbug-followup
Date:
February 6, 2003 11:29
Subject:
[perl #20765] bug in documentation of Class::struct
Message ID:
rt-20765-50475.11.8904246807047@bugs6.perl.org
# New Ticket Created by  DGWasson@uss.com 
# Please include the string:  [perl #20765]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20765 >


Hello,
     I think there is a typo in the example section of the documentation of
Class::struct at

http://www.perl.com/doc/manual/html/lib/Class/Struct.html

In example 1 it says {

use Class::Struct;



         struct( rusage => {
             ru_utime => timeval,  # seconds
             ru_stime => timeval,  # microseconds
         });



         struct( timeval => [
             tv_secs  => '$',
             tv_usecs => '$',
         ]);



             # create an object:
         my $t = new rusage;
             # $t->ru_utime and $t->ru_stime are objects of type timeval.



             # set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
         $t->ru_utime->tv_secs(100);
         $t->ru_utime->tv_usecs(0);
         $t->ru_stime->tv_secs(5);
         $t->ru_stime->tv_usecs(0);

}



I think example 1 should say {

use Class::Struct;



         struct( rusage => {
             ru_utime => timeval,
             ru_stime => timeval,
         });



         struct( timeval => [
             tv_secs  => '$', # seconds
             tv_usecs => '$', # microseconds
         ]);



             # create an object:
         my $t = new rusage;
             # $t->ru_utime and $t->ru_stime are objects of type timeval.



             # set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
         $t->ru_utime->tv_secs(100);
         $t->ru_utime->tv_usecs(0);
         $t->ru_stime->tv_secs(5);
         $t->ru_stime->tv_usecs(0);

}



I know this is some kind of reference to C language Unix DLL's but
shouldn't we trying to be less esoteric?  wouldn't it be more readable if
example 1 said {

use Class::Struct;



         struct( rusage => {
             ru_utime => timeval,
             ru_stime => timeval,
         });



         struct( timeval => [
             seconds      => '$',
             microseconds => '$',
         ]);



             # create an object:
         my $t = new rusage;
             # $t->ru_utime and $t->ru_stime are objects of type timeval.



             # set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
         $t->ru_utime->seconds(100);
         $t->ru_utime->microseconds(0);
         $t->ru_stime->seconds(5);
         $t->ru_stime->microseconds(0);

}

Thank you.




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About