in reply to Re^5: find a substring of unknow lenght if it is in a hash
in thread find a substring of unknow lenght if it is in a hash
... I'm not sure if I defined the empty-string key in the hash as you have asked me, did I do it correctly?
One way to see for yourself what a hash or array or arbitrarily complex structure of hashes and/or arrays contains is with the utility Data::Dumper, which IIRC is core and so should be supplied as part of any Perl installation, or with a similar utility such as Data::Dump, which I like. There are many other such utilities.
Do consider the documentation for index. Also consider the true/false values of the values index can return: -1 if a substring is not found, an offset of 0 or more if a substring is found; some simple experiments may help here.
Also perhaps consider if it's ever possible not to find the empty string in any other string, even in the empty string itself. Again, experimentation may be helpful.
I will have more time tomorrow to respond to the questions in your reply if others have not already done so. (Update: Actually, I could not say much more nor better than kcott does in his reply below.)
Give a man a fish: <%-(-(-(-<
|
|---|