RosettaCodeData/Task/Add-a-variable-to-a-class-instance-at-runtime/Perl/add-a-variable-to-a-class-instance-at-runtime.pl
2023-07-01 13:44:08 -04:00

12 lines
186 B
Perl

package Empty;
# Constructor. Object is hash.
sub new { return bless {}, shift; }
package main;
# Object.
my $o = Empty->new;
# Set runtime variable (key => value).
$o->{'foo'} = 1;