in reply to Re^3: Looking for function similer to member() in SKILL
in thread Looking for function similer to member() in SKILL

Anonymous Monk,
Please read Writeup Formatting Tips to make your posts clearer in the future. Additionally, you may want to look at perlstyle or Perltidy to make your code clearer. You should also start using strictures and warnings and possibly even diagnostics as they will help you to find problems on your own.

Now on to specific problems with your code. The next unless /@arr[$index]/ should be using the $ sigil as you are talking about a single element. In fact, this line makes little sense anyway as you are checking to see if the line matches your array, and then you are checking it again by matching using a regex. There is no need to match twice. Of course, this won't work for a couple of reasons - the first is that you are not chomping the line so it will never match because of a newline at the end. The second is that you aren't even reading the file - your while () { ... } should really be while ( <IN> ) { ... }.

There are more problems but I think you need to take a step back. Try starting out with the smallest piece of working code you can imagine and build on it checking the result each time. The first time it doesn't do what you expect, look there for the problem. For instance - start out reading a file and printing the contents.

Cheers - L~R

Replies are listed 'Best First'.
Re^5: Looking for function similer to member() in SKILL
by Anonymous Monk on Jun 27, 2005 at 14:27 UTC
    Hi L~R,
    Sorry I made a mistake posting the message. In my actual code I am reading
    while (<IN>) {...}. Also I tried using chomp but I don't get the right output.

    regards riz.
      riz,
      In my actual code...

      It is rather difficult to help if you don't actually post your actual code. I was hoping something would indicate why you have a valid reason why you can't use a hash instead of an array?

      I am not trying to be mean, but you are not being very effective in asking your question. Perhaps in addition to the other suggestions I provided, you might want to look at How do I post a question effectively?.

      Cheers - L~R