in reply to Re: Scripting Help
in thread Scripting Help

Sorry I have been so frustrated with it after working on it for 6 hours lol. The issue I get for adding a group is: Can't use string ("Test2") as a HASH ref while "strict refs" in use at ./example3 line 35, <> line 2. The error I get for deleting a group that I made previously in an earlier class, I get: Can't use string ("Test") as a HASH ref while "strict refs" in use at ./example3 line 44, <> line 2.

Replies are listed 'Best First'.
Re^3: Scripting Help
by mr_ron (Deacon) on Dec 14, 2015 at 20:40 UTC

    In two places you repeat the code:

    my $group_name = get_input("Enter Group Name: "); if ( exists $group_name->{$group_name} ) {

    The sub get_input() returns a string which, as the error messages are telling you, you are trying to use as hash reference with exists. On the left side of the -> arrow $group_name is a hash reference and on the right side of the arrow it is a string and key to the hash. It looks like in read_doc you need to create a hash of groups and return a reference to it.

    Ron
Re^3: Scripting Help
by poj (Abbot) on Dec 14, 2015 at 20:32 UTC
    For the code you posted I get
    Global symbol "$group_id" requires explicit package name .. Global symbol "$choice" requires explicit package name ..
    poj
      explicit package name as in /etc/group? The choice is made prior to that, it only throws up after I add my groups name.
        Does your code have the line use strict; ?