Re: Using regex special characters from a string
- From: byulga@xxxxxxxxxxxxxxxxx ("Brian F. Yulga")
- Date: Wed, 09 Mar 2011 14:48:43 -0600
Thanks for the reading suggestions!
Brian Fraser wrote:
On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga <byulga@xxxxxxxxxxxxxxxxx <mailto:byulga@xxxxxxxxxxxxxxxxx>> wrote:Very informative! Also in the following section, "How can I tell whether a certain element is contained in a list or array? Hearing the word "in" is an indication that you probably should have used a hash, not a list or array, to store your data."
Uri and Jim have hit upon one of my major stumbling blocks with
learning Perl. There seems to be a difference of opinion on the
proper times to use hashes vs. arrays/lists...and how best to use
>>Use a hash. When you think the words "unique" or "duplicated", think "hash keys".
Also the Hashes chapter of Learning Perl has a section called something like "Why use Hashes," which seems fitting enough."counting words" is the fourth example :-) That section mentions that hashes are useful for related data, or database-like data, but wasn't entirely convincing for me because it didn't mention performance.
Same with the Hashes part of Modern Perl ( http://www.onyxneon.com/books/modern_perl/index.html ), in the "The Perl Language" chapter.A useful read, but similar to Learning Perl, it doesn't mention the performance aspect. In this situation, I think the perlfaq provides the most convincing argument.
For those that have heard of this book, I'm currently digesting
this piece of information:
Effective Perl Programming, 2nd Ed., Item 9: "Know the difference
between lists and arrays."
See Item 13: Use arrays or hashes to group data. Also, www.effectiveperlprogramming.com <http://www.effectiveperlprogramming.com>.
I don't know if others had this problem when learning Perl, but the TMTOWTDI "philosophy" sometimes makes it difficult for me to discover better ways of doing things after I find one clunky way that works (hence my recent purchase of Effective Perl Programming, with the intention of acquiring Perl Best Practices in the future).