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

Re: [Fun With Perl] Rewrite and simplify redux



Vicki Brown writes:
|	  # reformat...
|	  foreach $id (@ids) {
|	      $id = sprintf("SEQ ID NO: %s (%s)", $pairs{$id}, $id);
|	  }
|
|	  # and join together again...
|	  $line = join(', ', @ids);
|
|	  print("$line\n");
|# Other ways to do it?

I'd probably do it:

print join (', ', map {"SEQ ID NO: $pairs{$_} ($_)"} @ids), "\n";

I didn't test that but it should be close.

Also, Vicki's replacement I quoted above may not be correct, as it, unlike
the code fragments it replaces, modifies the entries in @ids, so there will
be problems if they're needed later in their original form.

Brian

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org