Here document as method parameter
- From: "Ender" <oldcode@xxxxxxxxx>
- Date: 31 Dec 2006 00:53:51 -0800
Hi all,
Is there any way to pass here document string as method parameter?
Suppose we have a demo object:
#########################
package Demo;
sub new {
bless {};
}
sub output {
my $self = shift;
print STDOUT shift;
}
#########################
I have tried two kinds of calling style:
1).
#########################
my $demo = Demo->new();
output $demo <<'EOF';
main()
{
printf("hello world\n");
}
EOF
#########################
This works fine.
2).
#########################
my $demo = Demo->new();
$demo->output <<'EOF';
main()
{
printf("hello world\n");
}
EOF
#########################
Perl will complain for syntax error, but it looks more conventional for
me.
Any help will be appreciated.
.
- Follow-Ups:
- Re: Here document as method parameter
- From: Paul Lalli
- Re: Here document as method parameter
- Prev by Date: Re: Is item in array
- Next by Date: What's being thrown away?
- Previous by thread: Is item in array
- Next by thread: Re: Here document as method parameter
- Index(es):
Relevant Pages
|