method bless perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting method bless perl
# 1  
Old 02-08-2011
Question method bless perl

Hi,
I am using perl with some EDA tool. There is an API function that can be iterate.
I try to check the ref and get that it is a string. I assume that it is a hash

sub aaa {
my $obj = shift;
$name = $obj->name;
print ref $obj,"\n";
foreach my $var(keys %{$obj}) {
my $val = %{$obj}->{$var};
print "$var = $val\n";
}
}

I get
spy
PTR = 184267833624
TYPE = 2
I guess that name is a methods. How can I know it's content ?
Regards,
Ziv
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Perl error: Can't call method "value" on an undefined value

Hi, I am running a perl script to automate a process and I keep running into a error can't find the "value" Can't call method "value" on an undefined value at process_file.pl line 44. file is CVS cell is ifdfdxrfmp.ksh Here is the script I have also attached it as well: ... (2 Replies)
Discussion started by: vpundit
2 Replies

2. Solaris

svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n

After a memory upgrade all network interfaces are misconfigued. How do i resolve this issue. Below are some out puts.thanks. ifconfig: plumb: SIOCLIFADDIF: eg000g0:2: no such interface # ifconfig eg1000g0:2 plumb ifconfig: plumb: SIOCLIFADDIF: eg1000g0:2: no such interface # ifconfig... (2 Replies)
Discussion started by: andersonedouard
2 Replies

3. Programming

message and method

Differentiate between the message and method. (2 Replies)
Discussion started by: robinglow
2 Replies

4. Shell Programming and Scripting

Method isSuccess not working right perl

Good morning all.... I have been learning Perl for about 2 months now and I guess I am getting there as much as I can however I am really stuck. I have a Perl script called postEvent.pl which uses a package called event.pm. PostEvent.pl depends on a meithod inside event.pm called isSuccess to... (0 Replies)
Discussion started by: LRoberts
0 Replies

5. Shell Programming and Scripting

Is a Perl method defined?

In my code, I know I can write... if ( defined &test_sub ) { test_sub(); } else { print "Subroutine doesn't exist"; } This tests the existence of the test_sub subroutine without actually calling it. If, though, I replace test_sub with a package method... if ( defined... (1 Reply)
Discussion started by: JerryHone
1 Replies

6. UNIX for Dummies Questions & Answers

perl bless function

hi i am not getting what exactly bless function do in perl explanation in perldoc is not very clear i tried to search on google but i am getting confused or rather not getting at all. can anybody explain in short what it does in following example as well as in general ? sub new { my... (1 Reply)
Discussion started by: zedex
1 Replies

7. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

8. Programming

Best Method for installing Perl Modules

Which is the perferred method of installing Perl modules on a Unix system? Is is CPAN or manually installing them via a tar file? Also can anyone point me in the right direction to a decent "how to" on configuring CPAN and how to perform custom installs from a tar? thanks:b: (2 Replies)
Discussion started by: metallica1973
2 Replies

9. Shell Programming and Scripting

Perl, FilePropStore Method

Guys, anyone familiar with this FileProp Store Method.. Im having Compilation Error whenever a value is stored into the tied hash. Run time error sub STORE { my ($self, $key, $value) = @_; my $name = $self ->{name}; unless ($PROPS{$key} and -w $name){ croak "Can't... (1 Reply)
Discussion started by: killerserv
1 Replies
Login or Register to Ask a Question
Encode::Encoding(3)					User Contributed Perl Documentation				       Encode::Encoding(3)

NAME
Encode::Encoding - Encode Implementation Base Class SYNOPSIS
package Encode::MyEncoding; use base qw(Encode::Encoding); __PACKAGE__->Define(qw(myCanonical myAlias)); DESCRIPTION
As mentioned in Encode, encodings are (in the current implementation at least) defined as objects. The mapping of encoding name to object is via the %Encode::Encoding hash. Though you can directly manipulate this hash, it is strongly encouraged to use this base class module and add encode() and decode() methods. Methods you should implement You are strongly encouraged to implement methods below, at least either encode() or decode(). ->encode($string [,$check]) MUST return the octet sequence representing $string. o If $check is true, it SHOULD modify $string in place to remove the converted part (i.e. the whole string unless there is an error). If perlio_ok() is true, SHOULD becomes MUST. o If an error occurs, it SHOULD return the octet sequence for the fragment of string that has been converted and modify $string in- place to remove the converted part leaving it starting with the problem fragment. If perlio_ok() is true, SHOULD becomes MUST. o If $check is is false then "encode" MUST make a "best effort" to convert the string - for example, by using a replacement character. ->decode($octets [,$check]) MUST return the string that $octets represents. o If $check is true, it SHOULD modify $octets in place to remove the converted part (i.e. the whole sequence unless there is an error). If perlio_ok() is true, SHOULD becomes MUST. o If an error occurs, it SHOULD return the fragment of string that has been converted and modify $octets in-place to remove the converted part leaving it starting with the problem fragment. If perlio_ok() is true, SHOULD becomes MUST. o If $check is false then "decode" should make a "best effort" to convert the string - for example by using Unicode's "x{FFFD}" as a replacement character. If you want your encoding to work with encoding pragma, you should also implement the method below. ->cat_decode($destination, $octets, $offset, $terminator [,$check]) MUST decode $octets with $offset and concatenate it to $destination. Decoding will terminate when $terminator (a string) appears in output. $offset will be modified to the last $octets position at end of decode. Returns true if $terminator appears output, else returns false. Other methods defined in Encode::Encodings You do not have to override methods shown below unless you have to. ->name Predefined As: sub name { return shift->{'Name'} } MUST return the string representing the canonical name of the encoding. ->mime_name Predefined As: sub mime_name{ require Encode::MIME::Name; return Encode::MIME::Name::get_mime_name(shift->name); } MUST return the string representing the IANA charset name of the encoding. ->renew Predefined As: sub renew { my $self = shift; my $clone = bless { %$self } => ref($self); $clone->{renewed}++; return $clone; } This method reconstructs the encoding object if necessary. If you need to store the state during encoding, this is where you clone your object. PerlIO ALWAYS calls this method to make sure it has its own private encoding object. ->renewed Predefined As: sub renewed { $_[0]->{renewed} || 0 } Tells whether the object is renewed (and how many times). Some modules emit "Use of uninitialized value in null operation" warning unless the value is numeric so return 0 for false. ->perlio_ok() Predefined As: sub perlio_ok { eval{ require PerlIO::encoding }; return $@ ? 0 : 1; } If your encoding does not support PerlIO for some reasons, just; sub perlio_ok { 0 } ->needs_lines() Predefined As: sub needs_lines { 0 }; If your encoding can work with PerlIO but needs line buffering, you MUST define this method so it returns true. 7bit ISO-2022 encodings are one example that needs this. When this method is missing, false is assumed. Example: Encode::ROT13 package Encode::ROT13; use strict; use base qw(Encode::Encoding); __PACKAGE__->Define('rot13'); sub encode($$;$){ my ($obj, $str, $chk) = @_; $str =~ tr/A-Za-z/N-ZA-Mn-za-m/; $_[1] = '' if $chk; # this is what in-place edit means return $str; } # Jr pna or ynml yvxr guvf; *decode = &encode; 1; Why the heck Encode API is different? It should be noted that the $check behaviour is different from the outer public API. The logic is that the "unchecked" case is useful when the encoding is part of a stream which may be reporting errors (e.g. STDERR). In such cases, it is desirable to get everything through somehow without causing additional errors which obscure the original one. Also, the encoding is best placed to know what the correct replacement character is, so if that is the desired behaviour then letting low level code do it is the most efficient. By contrast, if $check is true, the scheme above allows the encoding to do as much as it can and tell the layer above how much that was. What is lacking at present is a mechanism to report what went wrong. The most likely interface will be an additional method call to the object, or perhaps (to avoid forcing per-stream objects on otherwise stateless encodings) an additional parameter. It is also highly desirable that encoding classes inherit from "Encode::Encoding" as a base class. This allows that class to define additional behaviour for all encoding objects. package Encode::MyEncoding; use base qw(Encode::Encoding); __PACKAGE__->Define(qw(myCanonical myAlias)); to create an object with "bless {Name => ...}, $class", and call define_encoding. They inherit their "name" method from "Encode::Encoding". Compiled Encodings For the sake of speed and efficiency, most of the encodings are now supported via a compiled form: XS modules generated from UCM files. Encode provides the enc2xs tool to achieve that. Please see enc2xs for more details. SEE ALSO
perlmod, enc2xs perl v5.16.3 2013-04-29 Encode::Encoding(3)