Run Code
|
API
|
Code Wall
|
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
each_hash_function
Supriya
Updated Safe 2.1 Solution
bitSum 059-1
Array_with_shift_function
Array_with_join_function
Quotes
5_5
Price_supriya
Palindromic Dates