On Tue, 2002-06-25 at 03:28, David vd Geer Inhuur tbv IPlib wrote: > > Hello, > > Thanks for the solution Bob. > Changed some stuff and have 2 questions open. > > my $line; > my (%u, %g); > open(FILE, "< ${dir}/user.perm") or print "Failed opening file $!"; ## 1 > while ($line = <FILE>) { ## 2 > if ($line =~ /^user:/) { > $u{$_} = 1 for split(/,/, substr($line, 6)); ## 3 > } > if ($line =~ /^group:/) { > $g{$_} = 1 for split(/,/, substr($line, 7)); ## 4 > } > } > close(FILE); > > print "Invalid login"; exit unless $u{$pwuser} || $g{$group}; ## 5 > > 1) I don't like to die in my script as there are many files to read. And if I > can't open the current file I just want to continue with the rest of the files > So I always prefer printing. > 2) while my $line (<FILE>) didn't work, just a notation error. > 3) I don't need to split on spaces. The script that fills the user.perm is > designed to always : "user: vdgeerd,and,other ## Never mind. > BUT, What do you do with the <1> ?? Changing it to $1 doesn't matter too. > I keep empty places when doing a " foreach my $value(%u) { print $value; } " > chomp %u; didn't work either. > 4) Same as 3 > 5) I changed the && into || cause the user can have acces due to group or user > rights. > BUT, how do I combine a printing error message and an exit within the unless ?
if you need to print an error message and exit, use die: die 'Invalid login' unless $u{$pwuser} || $g{$group}; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]