Loading ...
Sorry, an error occurred while loading the content.
 

[PBML] Re: tr///

Expand Messages
  • a_z0_9_blah
    ... Perl ... last ... z/; ... $last_name$class_year, ; ... What would you do if a student doesn t have a middle name (or doesn t provide one)? Chris
    Message 1 of 9 , Aug 22, 2008
      --- In perl-beginner@yahoogroups.com, "sengebr" <sengebr@...> wrote:
      >
      > Charles,
      >
      > Yes, thank you for that clarification. I am fairly new at this
      Perl
      > stuff.
      >
      > What I truely need is this:
      >
      > All login IDs to be lower case.
      > Last names with spaces to have no spaces.
      > Last names with apostrophes, to have no apostrophes
      > Last names with hyphens to have the first initial of the first
      last
      > name with the remainder of the last last name.
      >
      > This is what I have:
      >
      > while (<USERLIST>) {
      > @name = split(/,/);
      > $first_name = $name[0];
      > $middle_name = $name[1];
      > $last_name = $name[2];
      > $id = $name[4];
      > $class_temp = $name[6];
      > $class_year = substr($class_temp,2,2);
      > $last_name = substr($last_name,0,9);
      > ($user_name = substr($first_name,0,1).substr
      > ($middle_name,0,1).substr($last_name,0,9).$class_year) =~ tr/A-Z/a-
      z/;
      > $password = substr($middle_name,$middle_len -5);
      > open(OUTFILE, ">>:NT Accounts:$infile.nt");
      > print {OUTFILE} "$user_name,";
      > print {OUTFILE} "$first_name
      $last_name$class_year,";
      > print {OUTFILE} "$password,,,,\n";
      > close(OUTFILE);
      > print ".";
      > }
      > close(USERLIST);
      >
      > So, for Mr. John James Vanwagner, his account would be jjvanwagner
      > for Mr. John James O'Brian, his account would be jjobrian
      > for Mr. John James Henry-Wagner, his account would be jjhwagner
      > for Mr. John James O'Brian-Van Wagner, his account would be
      > jjovanwagner.
      >

      What would you do if a student doesn't have a middle name (or
      doesn't provide one)?
      Chris
    Your message has been successfully submitted and would be delivered to recipients shortly.