Re: use of bless

2016-02-28 Thread Kent Fredric
On 28 February 2016 at 21:59, rakesh sharma wrote: > According to docs bless returns the reference to self. That just means that if you do: my $x = {}; my $y = bless $x, "THING"; $y and $x will both be the same thing, a {} blessed into "Thing" Its just more convenien

Re: use of bless

2016-02-28 Thread Shawn H Corey
On Sun, 28 Feb 2016 08:59:20 + rakesh sharma wrote: > > HI all > > I am using object oriented perl and saw return self as well as bless > being used According to docs bless returns the reference to self. Why > should we use both statements in the new method > &

Re: use of bless

2016-02-28 Thread kiranmcs
Can you share the code? I believe the bless is returning the reference to self, which is captured in a variable with name self and that variable is returned from new method. Does that explains it? Thanks Kiran. On 28 Feb 2016 9:00 am, "rakesh sharma" wrote: > > > HI all

use of bless

2016-02-28 Thread rakesh sharma
HI all I am using object oriented perl and saw return self as well as bless being used According to docs bless returns the reference to self. Why should we use both statements in the new method Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

Re: Inserting a new data structure in a bless reference

2012-01-15 Thread David Christensen
On 01/13/2012 07:25 PM, Parag Kalra wrote: my $obj = FooBar->new; $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 1. FooBar may or may not be implemented as a hashref.

Re: Inserting a new data structure in a bless reference

2012-01-14 Thread Shawn H Corey
w 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, creat

Re: Inserting a new data structure in a bless reference

2012-01-13 Thread Jeff Peng
于 2012-1-14 11:25, Parag Kalra 写道: 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 I don't thin

Inserting a new data structure in a bless reference

2012-01-13 Thread Parag Kalra
ay 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.

Re: bless $self, $class;

2006-02-17 Thread David Kaufman
Hi Ken! Ken Perl <[EMAIL PROTECTED]> wrote: > > what does the statement mean? > > bless $self, $class; Thar is what a perl monk says to a his students when he sneezes during a lesson and no one says "Gazunteit". -dave -- To unsubscribe, e-mail: [EMAIL PROTEC

RE: bless $self, $class;

2006-02-17 Thread Timothy Johnson
Also check out perldoc perltoot perldoc perltooc -Original Message- From: Kirill Ponomarew [mailto:[EMAIL PROTECTED] Sent: Friday, February 17, 2006 12:30 AM To: Ken Perl Cc: Perl Beginners List Subject: Re: bless $self, $class; On Fri, Feb 17, 2006 at 04:26:33PM +0800, Ken Perl

Re: bless $self, $class;

2006-02-17 Thread Chas Owens
On 2/17/06, Ken Perl <[EMAIL PROTECTED]> wrote: > what does the statement mean? > > bless $self, $class; snip This is how you make objects in Perl. The bless function adds some meta data to the variable that is blessed telling it that it is now of class $class. You will usually

bless $self, $class;

2006-02-17 Thread Ken Perl
what does the statement mean? bless $self, $class; -- perl -e 'print unpack(u,"62V5N\"FME;G\!Ehttp://learn.perl.org/> <http://learn.perl.org/first-response>

Re: bless $self, $class;

2006-02-17 Thread Kirill Ponomarew
On Fri, Feb 17, 2006 at 04:26:33PM +0800, Ken Perl wrote: > what does the statement mean? > > bless $self, $class; http://www.perl.com/doc/manual/html/pod/perlfunc/bless.html -Kirill -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECT

Re: bless

2004-02-21 Thread James Edward Gray II
On Feb 20, 2004, at 11:29 PM, R. Joseph Newton wrote: Jacob Chapa wrote: what does bless do? It gives the hash reference offered as the first argument access to the methods of the package named by the second argument. there is more, but this is an alright place to start. The effect is to

Re: bless

2004-02-20 Thread R. Joseph Newton
Jacob Chapa wrote: > what does bless do? It gives the hash reference offered as the first argument access to the methods of the package named by the second argument. there is more, but this is an alright place to start. The effect is to turn the hash reference into an object refere

Re: bless

2004-02-20 Thread Rob Dixon
Randy W. Sims wrote: > > On 02/20/04 01:35, Jacob Chapa wrote: > > > what does bless do? > > It depends on how much you know. ;-) > > Basically it takes a reference to a perl type and tags it as an object, > so that in addition to being a reference to a type, i

Re: bless

2004-02-20 Thread Randy W. Sims
= \%ahash; $href->{key} = 'value'; print $href->{key}; print HR; my $blessed_ref = bless $href; print $blessed_ref->{key}; print HR; sub say_hello { print "Hello, World!\n"; } $blessed_ref->say_hello(); print HR; use Data::Dumper; print Dumper($blessed_ref)

Re: bless

2004-02-20 Thread Randy W. Sims
On 02/20/04 01:35, Jacob Chapa wrote: what does bless do? It depends on how much you know. ;-) Basically it takes a reference to a perl type and tags it as an object, so that in addition to being a reference to a type, it now has special properties: primarily that it can have subroutines

Re: bless

2004-02-20 Thread WC -Sx- Jones
=pod Jacob Chapa wrote: what does bless do? =cut $object = {};# hash reference # bless $object into Data::Encoder class bless($object, "Data::Encoder"); bless($object); # bless $object into current package $obj = [3,5]; print ref($obj), " ", $obj->[1], "\n&qu

bless

2004-02-19 Thread Jacob Chapa
what does bless do? -jake -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: how to "bless" while "strict"?

2003-09-17 Thread George Schlossnagle
On Tuesday, September 16, 2003, at 09:26 PM, sfryer wrote: So ... what is the correct "strict" way to "bless $talking, Horse"? bless $talking, "Horse"; George -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: how to "bless" while "strict"?

2003-09-17 Thread Jeff 'japhy' Pinyan
On Sep 16, sfryer said: >use strict; > bless $talking, Horse; # <<<< this is the source of the problem Quote 'Horse'. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.

how to "bless" while "strict"?

2003-09-17 Thread sfryer
the error message it generates. > perl -w use strict; my $name= "Mr. Ed"; my $talking = \$name; bless $talking, Horse; # <<<< this is the source of the problem print Horse->speak, $talking->name, " says ", $talking->

Re: manual bless

2002-12-12 Thread Ruth Albocher
Nigel Wetters wrote: > On Wed, 2002-12-11 at 13:55, Ruth Albocher wrote: > > I need to "cast" a scalar reference (SCALAR0x) into a reference to > > an object that I can use. (in other words, bless it). > > How can I do it? > > my $object = bless $sca

Re: manual bless

2002-12-11 Thread Nigel Wetters
On Wed, 2002-12-11 at 13:55, Ruth Albocher wrote: > I need to "cast" a scalar reference (SCALAR0x) into a reference to > an object that I can use. (in other words, bless it). > How can I do it? my $object = bless $scalar_reference, 'Your::Class'; -- Nig

manual bless

2002-12-11 Thread Ruth Albocher
Hi all. I need to "cast" a scalar reference (SCALAR0x) into a reference to an object that I can use. (in other words, bless it). How can I do it? thanks, ruthie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: tie/bless interactions?

2002-03-14 Thread Dave Storrs
Peter and Jenda, Thank you both for your information and pointers, I appreciated them. I actually ended up doing something slightly different; I wanted to make method calls use identical syntax, whether they were going to the APC::Event or the Tie::DBI, so what I ended up doing

Re: tie/bless interactions?

2002-03-13 Thread Peter Scott
At 02:19 AM 3/14/02 +0100, Jenda Krynicky wrote: > > 3) If I bless %self out of the "Tie::Hash" space and into the > > "APC::Event" space, are the "Tie::Hash" functions going to stop > > working? (I assume so.) > >You can't bless a ha

Re: tie/bless interactions?

2002-03-13 Thread Jenda Krynicky
E > }; > > > my $class =ref $proto# Are we being called as a class or > || $proto# instance method? > || 'APC::Event'; > > bless \%self, $class; > } I think this should be OK. &g

tie/bless interactions?

2002-03-13 Thread Dave Storrs
=> 1, # Allow INSERT and UPDATE, # but not DELETE }; my $class =ref $proto# Are we being called as a class or || $proto# instance method? || 'APC::Event';

Re: bless function

2001-09-17 Thread _brian_d_foy
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Baby Lakshmi) wrote: > I really dont understand the functionality and advantages of using bless. bless() "tags" a reference with a package name, effectively turning it into an object. without bless you don't

Re: bless function

2001-09-17 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 17, baby lakshmi said: >should we have to use the bless fuction in the constructor alone we can >use the created object ($foo) to invoke the function. isnt it??? so whatz >the real advandage of using bless function??? and why we need to bless that >particular ob

Re: bless function

2001-09-17 Thread baby lakshmi
Hello Jeff, Thank you for ur reply. > >package Animal; > >sub named { > > my $class = shift; > > my $name = shift; > > bless \$name, $class; > >} > >sub eat{ > > my $class = shift; > > $class = ref($class) || $class; &g

Re: bless function

2001-09-14 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 14, baby lakshmi said: >package Animal; >sub named { > my $class = shift; > my $name = shift; > bless \$name, $class; >} >sub eat{ > my $class = shift; > $class = ref($class) || $class; > my $food = shift; > print "$class eats

bless function

2001-09-14 Thread baby lakshmi
hello friends, i have a doubt in the concept of blessing. package Animal; sub named { my $class = shift; my $name = shift; bless \$name, $class; } sub eat{ my $class = shift; $class = ref($class) || $class; my $food = shift; print "$class eats $food\n&qu

Bless you all

2001-08-31 Thread Edouard Beaugard
Thanks for all your replies, the backticks work! Ed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]