Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (25 sloc) 1.08 KB


Pearl implements Perl's autovivification in ruby. OpenStruct gets us 80% of the way there.

  irb(main):017:0> a =
  => #<Pearl>
  irb(main):018:0> a.pants.belt.buckle.burst = true
  => true
  irb(main):019:0> a
  => #<Pearl pants=#<Pearl ...>>
  irb(main):020:0> a.pants
  => #<Pearl belt=#<Pearl ...>>
  irb(main):021:0> a.pants.chores = 4
  => 4
  irb(main):022:0> a.pants
  => #<Pearl chores=4, belt=#<Pearl ...>>
  irb(main):023:0> a.pants.chores
  => 4


I may work out the details of an implementation where you include Perl::Auto and then you wouldn't even have to explicitly call, you could just use local variable names but that would be evil.

Source Code

Main repository is at



Pearl is released under the WTFPL.