in reply to Re: Attempting to fill a hash
in thread Attempting to fill a hash

GrandFather,
Thank You.
First off thank you for that little tip on word lists, very nice.
Two things
1. next unless length $deadstring; - I'm assuming this is to make sure that $deadstring is not an empty variable.
2. Worked perfectly when I tried it with the word list. However, once I tried using the actual file, it started reading the data wrong again. Is it possible that the coding of the file is causing the streamreader to interpert it wrong for perl?

Replies are listed 'Best First'.
Re^3: Attempting to fill a hash
by GrandFather (Saint) on Jun 06, 2008 at 04:00 UTC

    next unless length $deadstring; uses a statement modifier (the unless bit) which is rather like an if statement backwards. You can use if, unless, for and while as statement modifiers.

    Try copying and pasting from your file into the sample code where the word list is. If that shows the error you see with the real file then post the modified sample here. If it doesn't show the same error then most likely your editor is modifying the text somewhat. One possibility is that the file has different line endings than are native on your system. For example, you may have got the file from a *nix system and are running it under Windows or vis-versa.


    Perl is environmentally friendly - it saves trees