Hi Thomas,
Please, check my comments below.
On 8/5/12, Thomas Dean <[email protected]> wrote:
> Hi there,
>
> Under 'use strict;',
> when can I omit the bracket and just write something like
To omit the Parentheses, for the subroutine in Perl, you need to have
PREDECLARED the subroutine OR you call the subroutine after it must
been " fully " stated out.
See Example:
use warnings;
use strict;
sub print_out; ## predeclare the subroutrine
my @arr=1..10;
print_out @arr; ## call the subroutine without the Parentheses.
sub print_out{
my (@arr_in_the_sub)=@_;
print $_,$/ for @arr_in_the_sub;
}
__END__
# OR
use warnings;
use strict;
my @arr=1..10;
# subroutine "fully" functional
sub print_out{
my (@arr_in_the_sub)=@_;
print $_,$/ for @arr_in_the_sub;
}
print_out @arr; ## call the subroutine without the Parentheses.
__END__
Please, also check perldoc perlsub for more details.
Hope this helps
> sub1;
> instead of
> sub1();
> and when cannot?
>
> Thomas
>
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
>
--
Tim
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/