Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Toy singleton class
#perl 5.22.1 package Borg; #a crude implementation of the singleton pattern. sub new{my $init=sub{bless [], $_[0]}; my $cl=$_[0]; # &init does what new usually does eval "\$$cl\::{borg}//(\$$cl\::{borg}=&\$init)";} package main; $x=Borg->new; $y=Borg->new; $x->[0]=5; #now $y is also [5] print $y->[0]
run
|
edit
|
history
|
help
1
Please
log in
to post a comment.
Neha101736
Jeffy John Sam (101724)
testing anonymous routine dereference with alternate syntax
Hash-Nevil
neigh.pl
Sortttttttt
Hello
size_of_array
bitSum 059-1
2nd
Please log in to post a comment.