Hello all,

I wanted to find out if an input word is a valid login name
on my system or not.

So, I wrote this:

  16: sub warn_if_bogus {
  17:     # Check if $arg is a valid login name.
  18:     my $arg = shift;
  19:     chomp $arg;
  20:     warn "blah blah\n" if (glob("~$arg") !~ m{^ (/\w+)+ /$arg $}x);
  21: } # &warn_if_bogus

Guess what is wrong with this logic.

Scroll down to see a hint.





























Hint:

Here is the output of "&warn_if_bogus($_) for qw(ksp mary cje jackie);":

  => Use of uninitialized value in pattern match (m//) at ./lab/r2.pl line 20.
  => mary is bogus
  => Use of uninitialized value in pattern match (m//) at ./lab/r2.pl line 20.
  => jackie is bogus

All four are valid login names on my system, as seen below:

  || % echo ~ksp ~mary ~cje ~jackie
  || /d1/ksp /d1/mary /d1/cje /d1/jackie
  || %

peace,          || Operation Shoe Fly: Send your shoes to Afghan children:
--{kr.pA}       || http://tinyurl.com/6jnpf
-- 
We must believe in luck.  For how else can we explain the success of those
    we don't like?  -- Jean Cocteau, author and painter (1889-1963)
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to