I am reading through O’Reilly’s Programming Perl, 3rd Edition, and the text states that instead of using the ambiguous search pattern /$foo[bar]/, one should instead use /${foo[bar]}/ so that Perl doesn’t mistake [bar] for a character class. Am I missing something, or are both of these statements syntactically incorrect due to the fact that they are trying to index into an array using a bareword string? I’ve checked the book’s errata online and can’t find any mention of this being a mistake in the book. Is there some scenario that I am overlooking in which that code could be valid?
I am reading through O’Reilly’s Programming Perl, 3rd Edition, and the text states that
Share
Yes, you’re missing something:
barcan be a function call:The exact quote, from page 73 of Programming Perl, 4th edition, is: