From: Seanie [EMAIL PROTECTED]
Rob Dixon wrote:
map(s/$find/$replace/, @arr);
Haha yes you can, but if you want to write nasty code go for
grep s/$find/$replace/, @arr;
which also works.
True, but grep implies find stuff, while map implies do stuff, so your
nasty code is way, way,
yitzle schreef:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Consider:
s/\Q$find/$replace/ for(@arr);
--
Affijn, Ruud
Gewoon is een tijger.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
yitzle wrote:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Yes. Exactly that.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
yitzle wrote:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Yes, although the parentheses are redundant.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools
yitzle wrote:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Yep, you can do that. Or use map()
map(s/$find/$replace/, @arr);
--
[EMAIL PROTECTED] [pgp: 8A8FA6DE]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
On 4/25/07, Seanie [EMAIL PROTECTED] wrote:
yitzle wrote:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Yep, you can do that. Or use map()
map(s/$find/$replace/, @arr);
You should not use map in a void context,
Chas Owens wrote:
map(s/$find/$replace/, @arr);
You should not use map in a void context, it is bad form.
Care to explain?
Neither 'strict' nor 'warnings' complains, and it does what it says on the
tin, but if I've missed something fundamental here I'd be grateful to know
about it.
--
Seanie wrote:
yitzle wrote:
What's the best way to apply a RegEx to an array? For loop?
@arr = qw/dc2ds reew12dsfa df2fdw/;
s/$find/$replace/ for(@arr);
Yep, you can do that. Or use map()
map(s/$find/$replace/, @arr);
Haha yes you can, but if you want to write nasty code go for
grep
Sean King wrote:
Chas Owens wrote:
map(s/$find/$replace/, @arr);
You should not use map in a void context, it is bad form.
Care to explain?
Neither 'strict' nor 'warnings' complains, and it does what it says on the
tin, but if I've missed something fundamental here I'd be grateful to know
Rob Dixon wrote:
map(s/$find/$replace/, @arr);
Haha yes you can, but if you want to write nasty code go for
grep s/$find/$replace/, @arr;
which also works.
True, but grep implies find stuff, while map implies do stuff, so your
nasty code is way, way, nastier than mine - it masks the
Seanie wrote:
Rob Dixon wrote:
map(s/$find/$replace/, @arr);
Haha yes you can, but if you want to write nasty code go for
grep s/$find/$replace/, @arr;
which also works.
True, but grep implies find stuff, while map implies do stuff, so your
nasty code is way, way, nastier than mine -
On 4/25/07, John W. Krahn [EMAIL PROTECTED] wrote:
Seanie wrote:
Rob Dixon wrote:
map(s/$find/$replace/, @arr);
Haha yes you can, but if you want to write nasty code go for
grep s/$find/$replace/, @arr;
which also works.
True, but grep implies find stuff, while map implies do stuff, so
13 matches
Mail list logo