August 13 2020 Perl 7: An Opinionated Introduction Back

Eliminating Warnings (1)

        $ cat heed-syntax-warning.t
        use Test::More;
        SKIP: {
            # try to add a group as supplementary group
            my $root_uid = 0;
            skip "uid!=0", 1 if $< != $root_uid and $> != $root_uid;
            my @groups = split ' ', $);
            my @sup_group;
            setgrent;
            while(my @ent = getgrent) {
                next if grep { $_ == $ent[2] } @groups;
                @sup_group = @ent;
                last;
            }
            endgrent;
            skip "No group found we could add as a supplementary group", 1
                if (!@sup_group);
            $) = "$) @sup_group[2]";
            my $ok = grep { $_ == $sup_group[2] } split ' ', $);
            ok $ok, "Group `$sup_group[0]' added as supplementary group";
        }
        done_testing;


Home Last TOC Copyright © 2020 James E Keenan Back Next