mdunnbass has asked for the wisdom of the Perl Monks concerning the following question:
I have an array where most elements are words, but periodically, an element will be a simple left or right bracket, [ or ]. If I am looping throught the array, and I want to join the bracket element and the two trailing elements, why doesn't this work?:
I've also tried the following permutations, and none of them work:if ($array[$i] eq '[') { $array[$i] = join ('', $array[$i],$array[$i+1],$array[$i+2]); }
What silly little thing am I forgetting/missing/screwing up?if ($array[$i] eq q{[}) { #etc... if ($array[$i] eq "[") { #etc...
Thanks,
Matt
(back after a long hiatus)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test if variable is equal to a bracket?
by jdporter (Paladin) on May 16, 2007 at 21:59 UTC | |
by mdunnbass (Monk) on May 16, 2007 at 22:10 UTC | |
by liverpole (Monsignor) on May 16, 2007 at 22:19 UTC | |
by mdunnbass (Monk) on May 17, 2007 at 23:59 UTC | |
by graff (Chancellor) on May 16, 2007 at 22:27 UTC | |
|
Re: Test if variable is equal to a bracket?
by johngg (Canon) on May 17, 2007 at 09:33 UTC |