> Date: Thu, 1 Jun 2006 20:22:27 -0400 (EDT)
> From: Janet Marie Jackson
> Subject: Re: [Boston.pm] Perl Curses clarification
>
>      Thanks to those who have answered.  Let me clarify a bit more what I
> need to do.  We want to use $USER to verify a valid user before running
> the program, so this is very unlikely go on the web or have a web
> interface.

If you're trying to identify the person invoking the program, you
might want to shy away from $USER.  It's just an environment variable
- anyone can set it to anything.  (getpwuid($<))[0] will give you the
username based on the process uid.

Unless of course, you want to make it easy for anyone to set it to
anything.  Then by all means, use $USER :)


> The user can run the program by adding student names to the command line,
> in which case the choice will include only those students specified.
> Otherwise, based on the $USER, that person's section will be included.
> If the choice is to view scores, all students (or those from the args) and
> their scores will be shown.  If the choice is to enter scores, the user is
> asked which homework, then the program will allow the user to enter a
> score for each student for the stated homework.  At the end, the updates
> are written back to the file.

This could be done with plain old stdin.  It's been a while since I
built perl from source, but it's configuration program was a good
example of the approach (perl 5.6.  I don't know if it's still used
these days).  The configure program asked you questions and you typed
your answers to stdin.  The basic idea was something like this

  my $answer = undef;
  while (! defined($answer)) {
      print("Shall I bite your ankle? [y/n]> ");
      chomp($answer = <STDIN>);
      if ($answer =~ m/(?:y|n)/i) {
          last;
      }
      $answer = undef;
  }


HTH

Steve
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to