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
0
Please
log in
to post a comment.
XPPErrorLog
OSTL
Perl - Sort hash of filenames by file extension
Challenge 41 Task 1
2
taller in front
Perl programs
Hash
doctor
Lol
Please log in to post a comment.