Re: search & relplace question
- From: "Tassilo v. Parseval" <tassilo.von.parseval@xxxxxxxxxxxxxx>
- Date: Fri, 28 Oct 2005 11:25:28 +0200
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);
.
- Follow-Ups:
- Re: search & relplace question
- From: John W. Krahn
- Re: search & relplace question
- Prev by Date: OSDC (Melbourne, Australia) open for registrations
- Next by Date: Re: to parse a string
- Previous by thread: OSDC (Melbourne, Australia) open for registrations
- Next by thread: Re: search & relplace question
- Index(es):
Relevant Pages
|
|