Helliwell, Kim wrote:
> The following test script fails to compile, complaining that there are
> not enough arguments in the call to sub2.
>
> #!/bin/perl
>
> sub1("Hello, ");
> sub1("world\n");
>
> sub sub2($str)
> {
> print $str;
> }
>
> sub sub1($str)
> {
> sub2($str)
> }
>
> The basic problem is that I'm trying to call one subroutine from inside
> another. I'm sure I've had this work before, but there's clearly
> something I'm doing wrong this time.
It looks like you are trying to write a C program using Perl.
perldoc perlsub
You want something like:
#!/bin/perl
use warnings;
use strict;
sub1("Hello, ");
sub1("world\n");
sub sub2
{
my $str = shift;
print $str;
}
sub sub1
{
my $str = shift;
sub2($str)
}
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>