[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [Fun With Perl] Rewrite and simplify redux



>>>>> "Vicki" == Vicki Brown <vlb@cfcl.com> writes:


Vicki> #	Second replacement:
Vicki> #	(or, if 'split' is your friend, join should be your buddy too)

Vicki> 	  # reformat...
Vicki> 	  foreach $id (@ids) {
Vicki> 	      $id = sprintf("SEQ ID NO: %s (%s)", $pairs{$id}, $id);
Vicki> 	  }

Vicki> 	  # and join together again...
Vicki> 	  $line = join(', ', @ids);

Vicki> 	  print("$line\n");

print join ", ", map sprintf("SEQ ID NO: %s (%s)", $pairs{$id}, $id), @ids;

map is your friend too.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me