e4monsch
asked on
Urgent: Problems with FileHandle and objects
G'day! I have written following method code in a object.
sub method
{
my($self) = shift @_;
my($filename) = shift @_;
$self{m_filehandle} = \*$filehandle;
open($self{m_filehandle}, ">blabla");
print $self{m_filehandle} "qwerqwerqwer";
...
}
I always get the following error:
String found where operator expected at Makefile.pm line 31, near "} "qwerqwerqwer""
(Missing operator before "qwerqwerqwer"?)
syntax error at Makefile.pm line 31, near "} "qwerqwerqwer""
BEGIN failed--compilation aborted at makefiletest.pl line 1.
Can someone tell me what the problem is and how to solve it?
sub method
{
my($self) = shift @_;
my($filename) = shift @_;
$self{m_filehandle} = \*$filehandle;
open($self{m_filehandle}, ">blabla");
print $self{m_filehandle} "qwerqwerqwer";
...
}
I always get the following error:
String found where operator expected at Makefile.pm line 31, near "} "qwerqwerqwer""
(Missing operator before "qwerqwerqwer"?)
syntax error at Makefile.pm line 31, near "} "qwerqwerqwer""
BEGIN failed--compilation aborted at makefiletest.pl line 1.
Can someone tell me what the problem is and how to solve it?
ASKER
Okay, it works! But can you tell me why it must be done like this?
Regards Jan
Regards Jan
ASKER
Another question. I have following code I always get the an error:
Can't use an undefined value as a symbol reference at v:\implementation\make\cre atemakefil e.pl line 196.
Code:
&main();
sub main {
my($fileHandle) = \*TEMPMAKEFILE;
open($fileHandle, ">test.txt")
or die("Could not create the file, stopped ");
print $fileHandle "asdfqwer"; #works fine
function($fileHandle);
...
}
sub function {
my($filehandle) = @_;
print $filehandle "asdf"; #produces an error
}
What's the problem here? It's really mad! Perl seems to behave absolutly asymetric! I tried to put the filehandle into braces {$filehandle} but it did not work.
Can someone tell how to correct the problem?
Regards Jan
Can't use an undefined value as a symbol reference at v:\implementation\make\cre
Code:
&main();
sub main {
my($fileHandle) = \*TEMPMAKEFILE;
open($fileHandle, ">test.txt")
or die("Could not create the file, stopped ");
print $fileHandle "asdfqwer"; #works fine
function($fileHandle);
...
}
sub function {
my($filehandle) = @_;
print $filehandle "asdf"; #produces an error
}
What's the problem here? It's really mad! Perl seems to behave absolutly asymetric! I tried to put the filehandle into braces {$filehandle} but it did not work.
Can someone tell how to correct the problem?
Regards Jan
ASKER
Forget the last comment. That code works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Forget the last comment. That code works.
print {$self{m_filehandle}} "qwerqwerqwer";