Sponsored Content
Full Discussion: perl bless function
Top Forums UNIX for Dummies Questions & Answers perl bless function Post 302307696 by zedex on Thursday 16th of April 2009 05:42:23 AM
Old 04-16-2009
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 ?

Code:
sub new {
        my $class                               = shift;
        my $self = {};
        bless ($self, $class);
}

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl split function

$mystring = "name:blk:house::"; print "$mystring\n"; @s_format = split(/:/, $mystring); for ($i=0; $i <= $#s_format; $i++) { print "index is $i,field is $s_format"; print "\n"; } $size = $#s_format + 1; print "total size of array is $size\n"; i am expecting my size to be 5, why is it... (5 Replies)
Discussion started by: new2ss
5 Replies

2. Shell Programming and Scripting

sort function in perl

Hi, here is my perl script.This script creates an array and is sorting it using the in-built sort function in perl. #!/usr/local/bin/perl my number=6; my @num_arr=(1,2,3,4,5); my @array=(23,"$number","Hello",2.345,@num_arr); #printing the array print... (2 Replies)
Discussion started by: DILEEP410
2 Replies

3. Shell Programming and Scripting

oct function in perl

hi i came across one program which uses some method to calculate file permissions using lstat in perl and i am not getting how its doing that i am pasting the code below ... $ > cat b.pl use Fcntl':mode'; my... (0 Replies)
Discussion started by: zedex
0 Replies

4. Shell Programming and Scripting

Join Function in PERL

Hi, Can any one please let me know, how to join the lines in a file, but based one a condition. There is a file, where few lines start with a date stamp. and few do not. I wanted to join the lines till I find a date stamp. If found date its should in a newline. Please help me. ... (5 Replies)
Discussion started by: thankful123
5 Replies

5. Shell Programming and Scripting

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... (0 Replies)
Discussion started by: zivsegal
0 Replies

6. Shell Programming and Scripting

Help !! perl open function

Help Please perl Gurus, I am trying to add ungrouped passengers in a group and I creating a script however it fails on first step only I tried all the options it returns following error. syntax error at junki line 4, near "open " Execution of junki aborted due to compilation errors. ... (2 Replies)
Discussion started by: dynamax
2 Replies

7. Shell Programming and Scripting

Perl split function

my @d =split('\|', $_); west|ACH|3|Y|LuV|N||N|| Qt|UWST|57|Y|LSV|Y|Bng|N|KT| It Returns d as 8 for First Line, and 9 as for Second Line . I want to Process Both the Files, How to Handle It. (3 Replies)
Discussion started by: vishwakar
3 Replies

8. Shell Programming and Scripting

perl function enquery

Dear all, I find a perl script that contains the following codes. Does anybody know the meaning of codes highlight. ..... @field = parse_csv($file); chomp(@field); ........ ........ sub parse_csv { my $text = shift; my @new = (); push( @new, $+ ) while $text =~ m{... (9 Replies)
Discussion started by: eldonlck
9 Replies

9. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies
MooseX::Attribute::ChainedClone(3pm)			User Contributed Perl Documentation		      MooseX::Attribute::ChainedClone(3pm)

NAME
MooseX::Attribute::ChainedClone - Attribute that returns a cloned instance VERSION
version 1.0.1 SYNOPSIS
package Test; use Moose; has debug => ( traits => [ 'ChainedClone' ], is => 'rw', isa => 'Bool', default => 0, ); sub complex_method { my $self = shift; #... print "helper message" if $self->debug; #... } sub clone { my $self = shift; # custom clone code here # defaults to: return bless { %$self }, ref $self; } 1; Which allows for: my $test = Test->new; $test->debug(1)->complex_method; # debug enabled # complex_method is called on a cloned instance # with debug set to 1 $test->complex_method; # debug is still disabled on $test $test->debug(1); # returns a cloned $test instance with debug set to 1 $test->debug; # returns 0 DESCRIPTION
MooseX::Attribute::ChainedClone is a Moose Trait which allows for method chaining on accessors by returning a cloned instance of $self on write/set operations. If $self has a "clone" method, this method is invoked to clone the instance. This allows for easy integration with MooseX::Clone or any custom made clone method. If no "clone" method is available, the new instance is build using "bless { %$self }, ref $self". AUTHORS
o Moritz Onken <onken@netcubed.de> o David McLaughlin <david@dmclaughlin.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Moritz Onken. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-01-28 MooseX::Attribute::ChainedClone(3pm)
All times are GMT -4. The time now is 03:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy