use strict; use warnings; { package SomeThing; my @verbose; sub new{ my ($class,%params) = @_; return bless {%params, }, $class; } sub get_info{ my ($self) = @_; return \@verbose; } sub insert{ my ($self,$opt,$info)=@_; push @verbose, "\n" . (my $time = ((scalar localtime)=~/(\d\d:\d\d:\d\d)/)[0]) . " \[$info]\n"; return unless $opt->{VERBOSE}; if(length($info) > 55){ $info =~ s/(.{1,50})/$1-]\n\t [-/; } print "$time [$info]\n"; } } my $obj = new SomeThing(color=>"Blue"); $obj->insert ({VERBOSE=>1}, "This text"); $obj->insert ({VERBOSE=>1}, "That text"); print $_ for @{ $obj->get_info()};