Hi Gurus,
I am trying to do (read/write/append) operations on file using oops in perl.
But I am getting the following error
Bareword "FileOperations" not allowed while "strict subs" in use at
readwriteapp
end.pl line 14.
BEGIN not safe after errors--compilation aborted at readwriteappend.pl line
22.
I have declared my $file in constructor (new) and blessed it with a class so
that I can use it in another method of the same class, but I cannot do so.
Can somebody help me in understanding where am I going wrong and the correct
way of doing the same.
--SNIP
use strict;
use warnings;
package FileOperations;
sub new
{
my $file="$_[0]";
my $err_code=1;
bless $file, FileOperations;
}
sub readfile
{
use File::Slurp qw (read_file);
my $text=read_file('$file');
return $text;
}
my $content=FileOperations::readfile($ARGV[0]);
-SNIP
Thanks in Advance,
PP.