On Oct 9, 2006, at 10:35 AM, Helliwell, Kim wrote:
#!/bin/perl
sub1("Hello, ");
sub1("world\n");
sub sub2($str)
{
print $str;
}
sub sub1($str)
{
sub2($str)
}
Prototyping in perl does not do what you think it does. It does not
turn your arguments into variables. All it does is supply a scalar or
list context to entries in your argument list. It is not a useful
feature for most people most of the time, and should be avoided.
http://library.n0i.net/programming/perl/articles/fm_prototypes/
Arguments to subs are always in the array @_
#!/bin/perl
use warnings;
use strict;
# no Top::Posting;
sub1('Hello, ');
sub1("world\n");
sub sub2 {
my $str = shift; # implicitly uses @_
print $str;
}
sub sub1 {
my $str = shift;
sub2($str)
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>