You might want to use something like DBM::Deep that lets you tie a hash into a file. Thus, you get the simplicity of using a hash for quick access and the persistence of the data in a file.
| [reply] |
I could use a hash but if the bot ever goes down then the list of protected users is gone. Thats why Im opening the list from a .txt file and putting the contents in the an array.
I personally believe that if you can open the list from a .txt file an put its contents into an array, then you could also put them into an a hash. unless you meant in some other way! ;)
| [reply] [d/l] |
And I did not understand this
use List::Util qw( first );
my $pro = first { $user[0] eq $_ } @protected;
do_stuff_with( $pro ) if defined $pro;
| [reply] [d/l] |
my $pro = first { $user[0] eq $_ } @protected;
assigns to $pro the first value in @protected which is equal to $user[0], that is, $user[0] itself, if the latter is in @protected, or else an undefined value. Thus the following line chooses what to do depending on whether $pro is defined or not, which appears to be what you want, ain't it?
| [reply] [d/l] [select] |