David Vd Geer Inhuur Tbv Iplib wrote: > > Hi, Hello,
> I need some help on the following. > In my script I show users some infodocs after they are verified to be valid users. > Users can have the permissions following the ruleset: > - user (all perm) > - group (all perm), > - descr (Not allowed to actualy open this document). > > Now I do the following in my script : > > # ------------- > open(FILE, "< ${dir}/user.perm"); You should _always_ verify that the file was opened. open FILE, "$dir/user.perm" or die "Cannot open $dir/user.perm: $!"; > my @users = <FILE>; > close FILE; > chomp (@users); > > my @out = grep {/$pwuser/} @users; > my @out1 = grep {/$group/} @users; > if ((!(@out)) && (!(@out1))) { print "Sorry $pwuser you have no acces to this >IP-Block"; exit; } > # -------------- > > But if a user with description access enters the complete link right now, > he can view the entire document. > Anyway, How do I build in an if-statement in here ?? > I know I can change the foreach loop and build the if statement within the loop, > but isn't there something like : > > my @out = if (m/user:/) { grep {/$pwuser/} } @users; ## This doesn't work > my @out1 = if (m/group:/) { grep {/$group/} } @users; ## This doesn't work > > an example of the file user.perm would be : > user: vdgeerd, tester > group: none, > descr: all, my @out = grep { /^user:\s*$pwuser$/ or /^group:\s*$group$/ } @users; unless ( @out ) { print "Sorry $pwuser you have no acces to this IP-Block"; exit 1; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]