in reply to Re: Replacing multiple matches
in thread Replacing multiple matches
The problem with the given code is the use of .*, which your solution doesn't solve at all. In fact, your solution doesn't address any problem. It's just adding slowness. It's worse than not giving an answer.#!/usr/bin/perl use strict; use warnings; my $loop_line = "static replace [something] and [another] thing"; my @matches = $loop_line =~/\[(.*)\]/; # Build a list of matches for ( @matches ) { $loop_line =~ s/\Q$_\E/PING/; } print $loop_line, "\n"; __END__ static replace [PING] thing
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Replacing multiple matches
by Berik (Sexton) on Feb 17, 2004 at 00:05 UTC | |
by Abigail-II (Bishop) on Feb 17, 2004 at 00:32 UTC |