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 ?
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 ?
The bless() function turns a vanilla reference (that can be virtually any type of reference, although hash reference is used most of the time) into an object. Without bless(), you are not doing object-oriented programming in Perl.
The first line captures the package name. If one calls
(1) The package name "Some::Package" will be passed as the first argument if the arrow -> is used. I forgot exactly which manpage mentioned this, but it should be there.
(2) You just create a reference type that holds the model of the object. However, the object itself has not been created yet.
(3) This is what creates the object. The reference (model) is associated with the given package name, so making the resulting object an instance of that package. (In OOP, objects are instances of a package/class/module).
It looks bizarre, but that's the way Perl objects work.
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)
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)
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)
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)
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)
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)
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)
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)
$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)