Prev: FAQ 6.5 I put a regular expression into $/ but it didn't work. What's wrong?
Next: Module to print hash?
From: Peng Yu on 6 Jun 2010 18:12 Suppose I new an object. Is there a way to get the class name from the reference to the object?
From: sreservoir on 6 Jun 2010 18:34 On 6/6/2010 6:12 PM, Peng Yu wrote: > Suppose I new an object. Is there a way to get the class name from the > reference to the object? perldoc -fref -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe."
From: Jens Thoms Toerring on 6 Jun 2010 18:35 Peng Yu <pengyu.ut(a)gmail.com> wrote: > Suppose I new an object. Is there a way to get the class name from the > reference to the object? The ref() function should return the name of the package of the object - I guess that's what you mean by "class name". Regards, Jens -- \ Jens Thoms Toerring ___ jt(a)toerring.de \__________________________ http://toerring.de
From: Dr.Ruud on 6 Jun 2010 18:45 Peng Yu wrote: > Suppose I new an object. Is there a way to get the class name from the > reference to the object? #!/usr/bin/perl -l use Data::Dumper; use Scalar::Util qw( blessed reftype ); my $object = bless [], __PACKAGE__; sub info { Dumper \@_ } my $i; print ++$i, ":\t", $_ for $object->info(), Dumper ( $object ), ref ( $object ), blessed( $object ), reftype( $object ), ; __END__ -- Ruud
From: chad on 9 Jun 2010 11:16 On Jun 6, 3:35 pm, j...(a)toerring.de (Jens Thoms Toerring) wrote: > Peng Yu <pengyu...(a)gmail.com> wrote: > > Suppose I new an object. Is there a way to get the class name from the > > reference to the object? > > The ref() function should return the name of the package of the > object - I guess that's what you mean by "class name". > Is there more than one defintion to "class name"? Chad
|
Next
|
Last
Pages: 1 2 Prev: FAQ 6.5 I put a regular expression into $/ but it didn't work. What's wrong? Next: Module to print hash? |