Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This fixes both those bugs, but there may be other edge cases.

The fudge wasn't necessary once I fixed the real problem:) Yes. 'ZZZZZZZZZZZ' is a fudge, but I am re-using mapNM which is a utility routine that wasn't specifically design for this case and this is the 'cheap fix' to flush the pump.

#! perl -slw use strict; sub mapNM (&@) { my $code = shift; map{ local( *a, *b ) = \( @_[ 0, 1 ] ); $code->(shift); # } 0 .. @_ - 2 } 0 .. @_ - 1 } sub strcmp{ my( $p, $b ) = ( $_[2]||0, 0 ); $p++ until $b = substr( $_[ 0 ], $p, 1 ) cmp substr( $_[ 1 ], $p, 1 ); $p * $b; }; my @names = sort map{ join' ', map{ $_ = ucfirst } split '[^a-z0-9]+', + lc } <DATA>; my %abbrev; print "@$_" for mapNM{ if( defined $b ) { my $n = 0; while( exists $abbrev{ $a->[ 0 ] } or $a->[ 0 ] eq $b->[ 0 ] ) { $n = strcmp $a->[ 1 ], $b->[ 1 ], abs($n)+1; if( $n ) { $a->[ 0 ] .= substr( $a->[ 1 ], abs $n, 1 ); $b->[ 0 ] .= substr( $b->[ 1 ], abs $n, 1 ); } } } $abbrev{ $a->[ 0 ] } = undef; $a } sort{ $a->[ 0 ] cmp $b->[ 0 ] } map{ [ join('', m[([A-Z])]g), $_ ] #} @names, 'ZZZZZZZZZZZZ'; } @names;
AAM A A Milne AAMr A A Milner AB Amanda Basile AC Alvaro Cangemi AD Annabelle Ducker AGl Allan Goris AGn Anthony Granado AHd Adam Harper AHs Ashlee Hurtt AK April Kain AM Anthony Mcdevitt AO Albert Osterman AP Alan Pfaff ARe A Remus ARi A Ripper ARer A Robertson ARin A Robinson AR A Rupee ARl Allan Razor ARlm Alma Ratcliffe ARrt Arthur Ragsdale ARS Alphonse Romeo Smith ASa Alana Stutsman ASi Alison Sands ASn Antonio Starnes ASr Arlene Stephen AS Armand Stower AV Alan Vanwinkle Ba Ballentine Bi Binns B Brittian BAB Big Al Bundy BD Brandon Dominick BE Bobby Eaton BN Brittanie Noviello BP Blanche Page BSe Bertha Schuck BSi Billy Sundberg BTe Bernice Turnage BTu Bulah Twombley BW Bobby Winkelman BZ Beata Zar CB Carey Balck CCa Candace Cote CCh Chris Creekmore CD Clinton Dahmen CE Clayton Elbert CGa Carey Grishaber CGh Chad Guarino CG Clinton Ganley CL Cheryl Langley CMa Clare Milum CMi Clinton Mcnaught CP Chandra Puffer CR Cody Ridout CT Carey Twedell CV Cody Vigo Di Dilbert Do Doggett DA Doris Adkins DB Darryl Buchta DC Daniel Colunga DHl Dale Hernandes DHn Dane Hasychak DS Debbie Schlueter DT Darren Tacey DV Darren Vanaman EB Eileen Bard EC Ernest Cowley ED Erik Duley EF Ernest Frey EG Eve Goodfellow EHi Elizabeth Hendricks EHn Elnora Hornbuckle EHic Ericka Hodgin EHne Ernest Helmick EK Esmeralda Kardos ER Elinor Rita ES Elwood Steketee EV Ewa Villerreal FJ Fidel Jacoway FL Florence Lillie FM Felicia Manson FO Fernando Outler FPi Fidel Paone FPr Fred Pyles G Guinn GGe Gerald Graziano GGu Guy Gatton GL George Lamoureux GM Gerald Minnich GN Gina Nickelson GR Gladys Rothman GT Genna Tranbarger GWl Glenda Wheat GWr Gregory Walls H Heinricher HC Hugh Charland HDa Harriet Dreyer HDu Hugh Dipalma HF Hugh Fuselier HH Harold Houser HM Hugh Minaya HQ Hannah Quijano HS Howard Sirois IM Inez Marion IN Ida Noe IPI I Palindrome I JA James Angell JBa Jamie Brickhouse JBo Joyce Brian JC James Cravens JGa Jami Gula JGe Jerri Giesen JG Ji Greenier JHa Jamie Huot JHe Jerri Houseknecht JMe Jeannette Macaluso JMo Jonathan Matos JN Jerri Nickson JO Jessie Olah JOB Jimmy O Brien JOL James O Leary JSo John Smith JSu Julio Sepeda JW Jason Willson K9 K9 Ki Kingsbury K Koteles KBl Keila Brue KBt Keith Berner KB Kevin Batchelder KCe Kenneth Caraballo KCi Kimberly Cecil KD Kathryn Diaz KHa Katherine Holzer KHe Kelly Henegar KH Kimberly Hare KK Kristina Kasper KL Katie Lloyd KPa Karina Palka KPe Kevin Poindexter LBa Larita Battisti LBo Louise Belanger LC Laurie Carranza LF Lilia Fouse LG Louisa Galyean LKi Linda Kavanaugh LKy Lynda Knudsen LLr Lorrie Lobdell LLu Louis Leggett LM Laura Mcfadden LP Linda Power LSn Lonnie Sherrow LSr Lori Stjohn LS Louisa Swingle LT Lakisha Trees LW Louis Watterson MAc Marcel Avers MAg Margaret Amey MBe Mae Brantley MBl Mallory Brodbeck MB Maricela Bautch MCa Marcel Cuffia MCi Mildred Colburn MF Maggie Fernandez MGa Marlin Gryniuk MGe Merrilee Garelick MH Mark Haynie MK Martin King MMg Maggie Madore MMr Marcel Merow MMa Mathew Mayton MMe Medhi Majesh MMc Mickey Mouse MMn Minnie Mouse MN Ming Negro MR Madelene Robasciotti MSl Mallory Sickels MSr Marilyn Shumpert MS Max Sprau MT Manuel Trotter NH Neil Helbert NL Nicholas Lowell NP Nelson Pinzon NR Nelson Rayo NS Nathan Shuster NTi Nicole Tillman NTo Norman Thatcher OB Olivia Bridgeman PA Peter Agee PK Priscilla Katz PL Peggy Loggins PM Penelope Maize PV Peter Valadez R Royce RDa Raphael Dumaine RDo Robyn Duvall RF Randy Frederickson RG Roger Goldman RK Roy Kushner RL Ronald Looney RM Rachel Marchand RN Raymond Nava RS Rod Schoneman Sc Schrock Sy Sydow SA Shawn Ault SC Stanley Cleaver SO Scott Obryan SS Sylvia Salazar SW Sylvia Walther T Tompkins TB Tarra Bellantuono TCh Thomas Coleman TCy Tyrone Crossett TDi Tia Drakeford TDo Tom Demarco TD Tom Denada TGa Tabatha Goodsell TGy Tyrone Golub TH Tony Haight TP Tina Palomo TT Tiny Tim TW Tari Windish VMc Victor Mcduffie VMo Viola Mcnamee VN Vincent Nowak WM Wayne Maye WU Wayne Ulrich YH Yolanda Hood

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

In reply to Re: Re: Re: Generate unique initials from a list of names by BrowserUk
in thread Generate unique initials from a list of names by EdwardG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found