[root@mysql1 perl]# cat 15.pl
#!/usr/bin/env perl
#use warnings FATAL => 'all';
sub sum_of_fred_and_barney {
print "hey, you called the sum_of_fred_and_barney subroutine!\n";
$fred + $barney;
}
sub sum_of_barney_and_fred {
print "hey, you called the sum_of_barney_and_fred subroutine!\n";
$fred + $barney;
print "hey, i'm returning a value now!\n";
}
$fred = 3;
$barney = 4;
$wilma = &sum_of_fred_and_barney;
print "\$wilma is $wilma.\n";
$betty = 3 * &sum_of_fred_and_barney;
print "\$betty is $betty.\n";
$wilma = &sum_of_barney_and_fred;
print "\$wilma is $wilma.\n";
$betty = 3 * &sum_of_barney_and_fred;
print "\$betty is $betty.\n";
[root@mysql1 perl]#
[root@mysql1 perl]#
[root@mysql1 perl]#
[root@mysql1 perl]# ./15.pl
hey, you called the sum_of_fred_and_barney subroutine!
$wilma is 7.
hey, you called the sum_of_fred_and_barney subroutine!
$betty is 21.
hey, you called the sum_of_barney_and_fred subroutine!
hey, i'm returning a value now!
$wilma is 1.
hey, you called the sum_of_barney_and_fred subroutine!
hey, i'm returning a value now!
$betty is 3.
#!/usr/bin/env perl
#use warnings FATAL => 'all';
sub sum_of_fred_and_barney {
print "hey, you called the sum_of_fred_and_barney subroutine!\n";
$fred + $barney;
}
sub sum_of_barney_and_fred {
print "hey, you called the sum_of_barney_and_fred subroutine!\n";
$fred + $barney;
print "hey, i'm returning a value now!\n";
}
$fred = 3;
$barney = 4;
$wilma = &sum_of_fred_and_barney;
print "\$wilma is $wilma.\n";
$betty = 3 * &sum_of_fred_and_barney;
print "\$betty is $betty.\n";
$wilma = &sum_of_barney_and_fred;
print "\$wilma is $wilma.\n";
$betty = 3 * &sum_of_barney_and_fred;
print "\$betty is $betty.\n";
[root@mysql1 perl]#
[root@mysql1 perl]#
[root@mysql1 perl]#
[root@mysql1 perl]# ./15.pl
hey, you called the sum_of_fred_and_barney subroutine!
$wilma is 7.
hey, you called the sum_of_fred_and_barney subroutine!
$betty is 21.
hey, you called the sum_of_barney_and_fred subroutine!
hey, i'm returning a value now!
$wilma is 1.
hey, you called the sum_of_barney_and_fred subroutine!
hey, i'm returning a value now!
$betty is 3.