in reply to Re^2: Help with split() function
in thread Help with split() function

I don't want to sound too harsh here, but you are missing many of the basics of Perl. You are using split(), arrays, regular expression matching, and "if" statements wrong. The only parts you have right are the ones you took from answers to your previous questions. You need to actually read your book and get familiar with the perl documentation if you want to Learn Perl. So far I can't see that you've learned anything but how to copy and paste.

I'll try to point you in the right direction anyways, though. Get one thing working at a time, and don't move on to the next thing until everything before it is doing what you want. I can tell you that "my @line = split ();" is not doing what you want it to. Read the perldoc for the split function.


-driver8

Replies are listed 'Best First'.
Re^4: Help with split() function
by negzero7 (Sexton) on Mar 19, 2008 at 01:57 UTC
    I disagree. My other code was fine and worked for the most part. Others gave advice and said what I have was a more correct way, so I have improved to use that. I don't consider that "copy and pasting".

    Could you please elaborate on why certain things are wrong? Telling me they are wrong and throwing me some documentation is only confusing me more. I can obviously tell it's wrong since it's not working.

    Maybe you could explain why it's out putting what it is?

      You're not going to want to hear this, but you should do the following faithfully:
      1. TYPE IN BY HAND every single example script, following along with the book. merlyn didn't write them for his edification.
      2. Do EVERY single exercise. merlyn didn't write them for him.
      3. Don't skip around. Every chapter builds on the previous one. If you finish a chapter, all the examples, and all the exercises and you're still confused, come to us with those specific questions, citing the chapter in the book you're confused with.

      Heck, if you're willing to actually take a learning attitude, I'd be willing to give you my email and talk with you directly. But, don't come to me if the sequence goes something like:

      1. I skimmed the chapter.
      2. I read the exercises, kinda.
      3. I tried to write something and it didn't work.
      4. I complained to someone that Perl is stupid.
      Every one of us didn't know Perl at some point or another. I taught myself Perl right out of Beginning Perl, first edition. You have the fourth edition. Lots of feedback has gone into it. If I can do it, so can you.

      UPDATE: Apparently, I've confused Beginning Perl with Learning Perl. merlyn wrote the latter and that's what I learned from. I can't recommend the book highly enough. However, every pedagogical book, such as Beginning Perl will teach you enough IF YOU DO THE WORK. Books aren't magical tools that somehow shove knowledge into your head. Don't treat them as such.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?