biohisham has asked for the wisdom of the Perl Monks concerning the following question:
my resources are so limited. With resources I mean examples, so I am a bit shaky when it comes to holding a grip over simulating user-defined data types.
The code I have is presented underneath but I think I don't fully understand what a user-defined-data type is in terms of (why would it be there if the arrays, hashes, scalars and Perl overall have an intelligence capability) due to the concise nature of the code.this code creates a data type called record that holds a value, its minimum possible and its maximum possible, I understood the mechanism of its working including the return of the anonymous hash and its reference thereof, but the concept is what I lack, so can a generous wiser monk make me understand why data types present themselves and what causes they do serve and how to get better at coming up with them.
sub record{ ($value, $max, $min)=@_; if($value>=$min && $value<=$max){ return{ #returning an anonymous ha +sh value=>$value, max =>$max, min =>$min, }; }else{ return; } } $myrecord=record(100,1000,10); print $myrecord->{max};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simulating user defined data types
by Your Mother (Archbishop) on Aug 07, 2009 at 18:07 UTC | |
by JadeNB (Chaplain) on Aug 07, 2009 at 21:51 UTC | |
by Your Mother (Archbishop) on Aug 07, 2009 at 22:15 UTC | |
|
Re: Simulating user defined data types
by JadeNB (Chaplain) on Aug 07, 2009 at 23:00 UTC | |
by biohisham (Priest) on Aug 08, 2009 at 17:37 UTC |