Debian Codegraph @

tests/branch_return_sub

raw
1 #!/usr/bin/perl
2
3 # Copyright 2004-2026, Paul Johnson ([email protected])
4
5 # This software is free. It is licensed under the same terms as Perl itself.
6
7 # The latest version of this software should be available from my homepage:
8 # https://pjcj.net
9
10 use strict;
11 use warnings;
12
13 sub my_sqrt {
14 my $n = shift;
15
16 if ( !defined($n) || ($n < 0) ) {
17 return undef;
18 }
19
20 return sqrt($n);
21 }
22
23 my_sqrt(25);
24 my_sqrt(-2);
25 my_sqrt(undef);