On 12-01-13 10:25 PM, Parag Kalra wrote:
The simplest way I thought of expressing this question is through
Pseudo-script so here it is:

use strict;
use warnings;
use FooBar;

my $obj = FooBar->new;
....
....
Do something
....
...
$obj->{'new_key'} = 'some_value'

Now I am not sure if that is the correct way of inserting a new data
structure into an already bless reference

My aim to use this data structure across the script and FooBar through the
object -$obj once added.


This could cause problems if a new version of FooBar starts using new_key. Instead, create your own object that has a FooBar one. That way you can use your own keys without worrying about collisions with future versions of FooBar.


$ cat MyFooBar.pm
package MyFooBar;

use strict;
use warnings;

use FooBar;

sub new {
  my $class = shift @_;
  my $self = { @_ };

  $self->{foobar} = FooBar->new();
  return bless $self, $class;
}

__END__

--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

Never give up your dreams.  Give up your goals, plans,
strategy, tactics, and anything that's not working but never
give up your dreams.

http://www.youtube.com/watch?v=cM5A1K6TxxM
"Never, never, never give up."
  Winston Churchill

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to