Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:53:44+00:00 2026-05-25T17:53:44+00:00

I would like to create a script that would add an AD account, but

  • 0

I would like to create a script that would add an AD account, but check for duplicates first.

Lets just say
$first = John
$last = Doe

The naming convention is “DoeJ”
If “DoeJ” already exists (example: Jane Doe), then it should be last name, first 2 characters of first name.. example: “DoeJo”. If “DoeJo” already exists, then last name, first 3 characters of first name, and so on…

How can I accomplish this?
I am looking for Sript examples, as I am new to Perl.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:53:45+00:00Added an answer on May 25, 2026 at 5:53 pm

    I just wanted to hack a bit before going to sleep. I’m sorry, I’m to lazy to explain anything right now, but I’m sure you will find pretty much, when looking for anything special on perldoc.

    @Everybody: Feel free to comment, modify, extend, beautify, whatever this code if you feel like that.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use Data::Dumper;
    
    my %accounts;
    
    while (<DATA>) {
        my ( $id, $first_name, $last_name ) = split;
        my $account_name = $last_name;
    
        for my $letter ( split ( "" => $first_name ) ) {
            $account_name .= $letter;
            last unless exists $accounts{ $account_name };
        }
    
        my ( $prefix, $suffix ) = ( $account_name, 0 );
        while ( exists $accounts{ $account_name } ) {
            $account_name = $prefix . ++$suffix;
        }
    
        $accounts{ $account_name } = "$id: $first_name $last_name";
    }
    
    print Dumper(\%accounts);
    
    __DATA__
    1 Jane Doe
    2 John Doe
    3 Joho Doe
    4 John Doe
    5 John Doe
    6 John Doe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a pipe in a ksh script (using exec) that
I would like to create a batch script, to go through 20,000 links in
I would like to create a WLST script to create my Weblogic domain. However
I would like to create my database tables in SMS then generate a script
I have written a small Perl script and now I would like to create
I would like create my own collection that has all the attributes of python
I would like create a web service in ASP.Net 2.0 that will supports JSON.
I'd like to create a .js script that will write the current system-time and
Would like to create a strong password in C++. Any suggestions? I assume it
I would like to create a database backed interactive AJAX webapp which has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.