I would like to be able to store objects in a hash structure so that I can work with the name of the object as a variable. Can someone help me make a sub new {...} which creates a new object as a hash element? I'm not quite sure how to do this or how to reference and / or use an object when it is stored like this. I just want to be able to use and refer to the name of the object for other routines.
See my comment in How can I get the name of an object in Perl? why do I want to do this.
thank
. ? , , .
, .
, , , -:
my %hash = ( some_name => Class->new( ... ), other_name => Class->new( ... ). );
, , Intermediate Perl, , .
, . , ?
, perl.
my %hash = ( ); $hash{'foo'} = new Foo(...); $hash{'bar'} = new Bar(...);
, , , "foo", Foo, "bar" - Bar, .
$hash{'foo'}->foo_method(); $hash{'bar'}->bar_method();
, . , .
Source: https://habr.com/ru/post/1762553/More articles:FullCalendar - how to disable the prev button - jqueryWhy does COW mmap fail with ENOMEM on (sparse) files larger than 4 GB? - linux-kernelMVC (not mvvm) for WPF? - model-view-controllerBinding library error c. The COMDAT symbol '.exc $ T' does not match the section name '.rdata' - c ++How to use the method of matching rails with a string? - regexRails / Passenger URI Error - ruby-on-railsPHP: moving directories with content? - phpHow can I get the name of an object in Perl? - objectWrappers around lambda expressions - pythonBest way to convert hex string to string in Java? - javaAll Articles