Questions tagged [bless]

Bless is a function in Perl, which associates an object with a class.

In , in order to use references (hard references, not soft references) as objects of a class (or package), we need to associate references with a class first. This is done by using the bless function.

21 questions
1
vote
4 answers

Is unblessing perl objects a dreadful design?

Is unblessing Perl objects means having a dreadful design ? If yes, can any one explain this to me ? BTW, Here's the discussion which fired this question, check comments on the question
Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
1
vote
1 answer

Perl how to get values from bless object request data

I am using RPC::XML and parsing request xml using below code and request xml. use RPC::XML::ParserFactory 'XML::Parser'; my $P = RPC::XML::ParserFactory->new(); my $parse_data = $P->parse($xml_data); print Dumper($parse_data); Request…
Laeeq
  • 403
  • 1
  • 3
  • 14
1
vote
3 answers

Perl : Get the keys of a blessed hashref

There are 2 packages in the code. Package 1 : package Foo; sub new { my ($class, $args) = @_; my $hashref = {'a' => 1, 'b' => 2}; bless ($self, $class); return $self; } Package 2 : package Fuz; use Foo; . . . . my $obj =…
Aman Vidura
  • 85
  • 2
  • 10
0
votes
1 answer

Perl: referencing/blessing question

The idea is to implement a class that gets a list of [arrays, Thread::Conveyor queues and other stuff] in a TIEHASH constructor, use AbstractHash; tie(%DATA, 'AbstractHash', \@a1, \@a2, \$tcq); What is a correct way to pass object references…
kagali-san
  • 2,964
  • 7
  • 48
  • 87
0
votes
2 answers

unbless implementation in Perl?

As many Perl developers know, unbless is used to remove the blessing from objects. I am trying to understand how does it internally work by investigating its implementation. I tried to check its implementation in its package Data::Structure::Util.…
Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
-2
votes
1 answer

I am trying to modify a method that returns an error string so that it can accept a hash in Perl

Here is the current method: sub new { my ($package, $message) = (shift, shift); my %params = @_; return bless { message => $message, %params }, $package; } This method returns basically an error string , but I want to modify it so it…
Paul Russell
  • 179
  • 10
1
2