Nicely display a reference to something (hash, array or scalar) in Perl

Below is a little function to display a reference to mainly a hash, array or scalar in Perl:

Code:

use strict;
use warnings;

our $indentationString = "    ";

sub recursive_ref_string
{ Continue reading 
Advertisements

Python Singleton

#!/usr/bin/python

class Singleton( object ):
        instance = None
        def __new__( className, *args, **kargs):
                print 'Getting %s instance' % className.__name__
                if className.instance is None:
                        print 'Creating new %s object' % className.__name__
                        className.instance = object.__new__( className, *args, **kargs );
                return className.instance
 Continue reading