Re: RegEx Substitution + Arrays

2007-05-10 Thread Jenda Krynicky
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,

Re: RegEx Substitution + Arrays

2007-04-26 Thread Dr.Ruud
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

RegEx Substitution + Arrays

2007-04-25 Thread yitzle
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/

Re: RegEx Substitution + Arrays

2007-04-25 Thread Rob Dixon
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/

Re: RegEx Substitution + Arrays

2007-04-25 Thread John W. Krahn
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

Re: RegEx Substitution + Arrays

2007-04-25 Thread Seanie
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]

Re: RegEx Substitution + Arrays

2007-04-25 Thread Chas Owens
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,

Re: RegEx Substitution + Arrays

2007-04-25 Thread Seanie
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. --

Re: RegEx Substitution + Arrays

2007-04-25 Thread Rob Dixon
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

Re: RegEx Substitution + Arrays

2007-04-25 Thread Rob Dixon
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

Re: RegEx Substitution + Arrays

2007-04-25 Thread Seanie
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

Re: RegEx Substitution + Arrays

2007-04-25 Thread John W. Krahn
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 -

Re: RegEx Substitution + Arrays

2007-04-25 Thread Chas Owens
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