What is the difference when calling a subroutine with and without and in Perl?

For my homework, I was told to make a routine inside Perl, and when it is called with arguments in it, it will print the arguments. I did this, and the second part of my homework was to call this first subroutine in the second. Therefore, I did all this, but then the question arose: try to start the second subroutine with & calling the first, and without it, and write what is the difference in these two different calls. Thus, the subroutine works fine in both cases, with and without, but I just don’t know that this has really changed, so I don’t know what to write. Off, does my code look fine? First time coding in this Perl.

This is the code:

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;

show_args('fred','barney','betty');

show_args_again();

sub show_args{
    my ($broj1, $broj2, $broj3) = @_;
    print "The arguments are: " . "$broj1, " . "$broj2, " . "$broj3.\n";
}
sub show_args_again{
    &show_args('fred','barney','betty');
}
+4
source share
2

, show_args_again ?

, , , .

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;

show_args('fred', 'barney', 'betty');
print "---\n";
show_args_again('fred', 'barney', 'betty');

sub show_args{
    my ($broj1, $broj2, $broj3) = @_;
    no warnings 'uninitialized';
    print "The arguments are: $broj1, $broj2, $broj3.\n";
}

sub show_args_again {
    show_args(@_);
    &show_args(@_);
    show_args();
    &show_args();
    show_args;
    &show_args;
}
+3

, , , , , , , . , :

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;


show_args("fred","barney","betty",);

show_args_again("fred","barney","betty");

sub show_args{ 
    print "The arguments are: ", join(', ', @_), ".\n"; 
}

sub show_args_again{
     &show_args; 
}

, "&" , , , - , "&"; , @_. - , . , , , , , , .

+1

All Articles