Re: Here document as method parameter
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Dec 2006 04:25:03 -0800
Ender wrote:
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;
}
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.
Very close. You just forgot the parentheses.
$demo->output(<<'EOF');
Paul Lalli
.
- References:
- Here document as method parameter
- From: Ender
- Here document as method parameter
- Prev by Date: Re: Is item in array
- Next by Date: Re: Is item in array
- Previous by thread: Here document as method parameter
- Next by thread: What's being thrown away?
- Index(es):