2007/10/4, Siva Prasad <[EMAIL PROTECTED]>: > Can somebody help me in understanding where am I going wrong and the correct > way of doing the same. >
Hi, Hope the codes below explain what you asked. $ cat FileOperations.pm package FileOperations; use strict; use warnings; use File::Slurp qw (read_file); sub new { my $class = shift; my $file=shift; bless {file=>$file},$class; } sub readfile { my $self = shift; my $file = $self->{file}; my $text=read_file($file); return $text; } 1; $ cat t1.pl use strict; use FileOperations; my $obj = FileOperations->new('/etc/hosts'); my $txt = $obj->readfile; print $txt; $ perl t1.pl # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 squid2 localhost.localdomain localhost -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/