Re: search & relplace question



Also sprach Ashwin:

> I am not able to understand why
> my @result =map ((s/BBI_DIR/BBI_DIR\\RBI/), @BBY); modifies the @BBY
> array,
> what I expected was that @result should get updated with replaced lines,
> but it only updated with value 1 , which is what search function
> returns on success

Precisely.

> if I try
>
> my @result =map ((s/BBI_DIR/BBI_DIR\\RBI/,$_), @BBY);
> @results and @BBY get the same value , but @result also gets those line
> which are replaces appended with 1,
> what I need is only @result to get updated

You can make a copy of $_ in the map block and apply s/// to that. Or
you use List::MoreUtils::apply() (courtesy of Brian McCauley) which is
just like map() only that it wont alter the input elements:

use List::MoreUtils qw/apply/;

my @result = apply { s/BBI_DIR/BBI_DIR\\RBI/ } @BBY;

Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
.



Relevant Pages

  • Re: Looking for speed performance to draw line.
    ... each item in an array, that being the next and/or previous indexes. ... and it's next pointer to the previous item's original next pointer. ... Next -1, Prev 0 ... shapes up into shape classes that implemented the required commands ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Multiple Condition Sumif Formula
    ... Andy. ... > revenue column. ... > & I've tried to enter the formula as an array by doing ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Row Compression
    ... Otherwise, use Jim's suggestion ... > And want to remove rows with a blank in column 1 and collapse the whole ... > array to get: ... Prev by Date: ...
    (microsoft.public.excel.misc)
  • scroll select
    ... arr = getMultiple; ... var keep_array = new Array; ... Prev by Date: ...
    (comp.lang.javascript)
  • Re: Variable Drop Down
    ... >my php script to recognize the value in "who" when potentially there ... >are 4 different values stored in the "who" array? ... >Can someone shead some knowledge? ... Prev by Date: ...
    (alt.php)