in reply to Re: Spliting letters in a string
in thread Spliting letters in a string
I really do believe that you already realize that this is dangerous and were just offering it as a "well, if that's really what you want to do then this is how you do it..." kind of thing.
Continuing in that spirit, some suggestions...
You should make sure that you don't conflict with use strict by doing a (block-scoped) no strict 'refs';. You might also want to local $_. I would also suggest avoiding using map in void context because it spends a lot of energy building a return list and actually tends to be slower than an equivalent for loop in many cases; and, IMHO, it doesn't really improve the legibility any.
{ no strict 'refs'; local $_ = "abcdefghijklmnopqrstuvwxyz"; # or $string $$_ = $_ for split //; } print $c; #prints letter 'c' to the screen
Of course, these are all just suggestions. You're code was perfectly useable to begin with. :-)
Update: Improved the wording a little. Removed unnecessary braces in deref in code. Changed no meaning. :-)
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (bbfu) (soft-refs) Re(2): Spliting letters in a string
by srawls (Friar) on May 08, 2001 at 05:05 UTC | |
by bbfu (Curate) on May 08, 2001 at 05:13 UTC |