On Jul 26, 7:14 am, [EMAIL PROTECTED] (Snickwad) wrote: > Apologies if this is a bit noobie,
As a newbie, you may not be aware that Perl comes with a built-in FAQ. You can see the whole thing by typing at your command window: perldoc perlfaq But the specific question you care about is: $ perldoc -q contain Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq4.pod How can I tell whether a certain element is contained in a list or array? > but I have been left with a short > window to write a tool and I have had no experience with Perl. Very > familiar with Kornshell, and so far my Perl script is going okay. > However, I am struggling to get a test working correctly. Is there a > simple way to test if a string does not exist in an array? > > I am trying to test if some user input (a userid) is valid and error > if it does not exist. Currently have the contents of /etc/passwd in an > array, No you don't. > and can test for valid users, but all my efforts to test for > invalid have failed miserably. > > I am on AIX, not sure on the Perl version. > > Current test for valid is : > > return 1 if (grep(/$user/,$udata)); $udata is not an array. It is a scalar. Arrays start with @. Scalars start with $. Now, if $udata happened to have one big string that contains all of the usernames that are valid, this would still "work". But seeing as you're calling it an array, I'm wondering if perhaps $udata is actually an array reference, in which case you'd need to derference it. You should read: perldoc perlreftut In general, there's no real solid answer of how to "fix" your code without knowing what your code actually is. Please post a SHORT but COMPLETE script when requesting help. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/