Anonymous user
Compound data type: Difference between revisions
→[[Perl|Perl TODO]]
(Reader included) |
|||
Line 202:
# Please verify the code above... (from CPAN docs, not tested)
# Using Class::Struct▼
use Class::Struct;▼
struct Point => [ x => '$', y => '$' ];▼
my $point = new Point( x => 1, y => 2 );▼
# Using Inline::Struct with C code embedded
use Inline C;
Line 233 ⟶ 227:
my $point = pack("ii", 1, 2);
my ($x, $y) = unpack("ii", $point);
# Using a hash for storage▼
my %point = ( x => 1, y => 2);▼
# Using Win32::API::Struct
Line 268 ⟶ 259:
#endif
typedef struct Point { int x; int y; } Point;
### The code below does not create a "binary" like structure.
▲ # Using Class::Struct
▲ use Class::Struct;
▲ struct Point => [ x => '$', y => '$' ];
▲ my $point = new Point( x => 1, y => 2 );
▲ # Using a hash for storage
▲ my %point = ( x => 1, y => 2);
==[[PHP|PHP TODO]]==
|