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 t

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. -- [E

Re: cat (.sh) in Perl

2007-04-25 Thread Seanie
John W. Krahn wrote: > > Your syntax for the open() statements is a bit dodgy too :-) > Perl defines the syntax so you must mean something else? :-) As in "too much unnecessary typing and commas and such, which don't really add clarity", rather than "incorrect" > You should also include the $!

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: Code Comments/Tips - Can this code be better?

2007-04-25 Thread Seanie
yitzle wrote: > I got an input source that got records of fixed number of lines, eg > Name, Address, Age, Phone, Cell > I'm not interested in Age or Cell. > I'm doing something along the lines of the following. Can I do better? > > my @lines = qw/name address age phone cell end/; > my %process = {n

Re: cat (.sh) in Perl

2007-04-25 Thread Seanie
yitzle wrote: > `cat m.top.html m.mid.html m.arc.html m.bot.html > blah` > How can this be done without a system call? As a general rule, if your script contains 'system()' anywhere in it, you've done it wrong. This is especially true for simple file operations such as the above, and for anythin

Re: Text munging problem

2007-04-06 Thread Seanie
Glenn Booth wrote: > I need to sort out the cases of the text fields (BOOK TITLE) > and ( a book about cats ) and render them to "Title Case" (first > character upper case for each word). > Anyone have an elegant way? ucfirst() does what you want: echo "hello world" | perl -ne 'print join " ", ma