in reply to Re: Need help with subdividing SGML files
in thread Need help with subdividing SGML files

Why do you bother wasting your time using strict, if all you are going to do is name every undeclared variable at the top of your program. It's pointless.

There are still two lines (at least) in your updated program that contain simple syntax errors that will prevent your program from doing anything like what you want it to do.

Look up the syntax of perl's for statements.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.
  • Comment on Re: Re: Need help with subdividing SGML files

Replies are listed 'Best First'.
Re: Re: Re: Need help with subdividing SGML files
by DukeLeto (Novice) on Mar 12, 2003 at 21:50 UTC

    1) Because I'm coming from a Visual Basic background where the strict definition of Variables at the top of the procedure/package is considered good practice.

    2) The debug program seemed to be prompting me to explicitly define all of the variables, so that's what I did.

    I take it that the syntax errors are so simple and that I've offended your sensibilities so severely that you can't be bothered to point them out.

    You seem to be implying that I'm using for and foreach incorrectly. I can't see how that would be. Perhaps you think the answer is so embarassing that I would rather figure it out for myself than live in the shame of having it explained to me. Also, you've twice declaimed that you don't know what I want, so it seems odd that you're so sure now.

    To put it bluntly, I find your tone to be insulting and if you don't want to give constructive criticism, I can do without your help.

      I put about as much effort into my answer as you have into your question, and your answers to requests for further information.

      As you seem incapable of reading documentation, I'll hold your hand a little further. This loop will execute exactly three times regardless of the values of any of the variables involved.

      for ($i = 0, $i < @InFileNames, $i++) {

      During the first iteration, $_ will be set to 0 (zero). During the second it will be set to either 0 or 1, most probably 1 unless @InFileNames is empty. The third iteration $_ will be set to 1.

      The value of $i will be zero for the first two iterations and 1 for the third.

      Similarly, this loop will also execute exactly 3 times regardless of the values of the variables involved

      for ($j = 0, $j < @OutFileNames, $j++){

      Again, $_ will take the values 0, 0|1, 1 during the three iterations. The value of $j will be 0, 0, 1 for those 3 iterations.

      It is pretty certain that this is not your intention. All the information regarding what is wrong, and how to put it right is available in

      • The documentation that came with your copy of perl. As you are on a windows platform, it is available in html format. To find ot you only need to look in the X:\yourpathto\perl\html directory and invoke the file index.html.
      • You could also use the command perldoc from a commandline.
      • look in the documentation available on this site.
      • or at perldoc.com

      If you had taken the constructively intended advice I offered, and looked up the syntax of for loops, I wouldn't have to be pointing these mistakes out to you.

      As for my tone........on my screen, it is black on white, any other tone you infer from the way the text is displayed on your screen is beyond my control.


      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.

        OK, you're right.

        I had somehow misread my Camel book and believed that any case in which an array variable is used in what is implicitly a scalar context would yield the length of the array. Looking back over the appropriate section (p. 76), I now see that the context must be implicit through operational use or explicitly stated.

        Of course, this makes no difference in the error I'm experiencing, because now that the "for" loop is operating properly, it still gets an error from @InFileNames[0] which hasn't been defined.

        I'll take your admonition to heart and look over the camel book at home this evening. Perhaps a more detailed reading of the glob function definition will yield the answers I need.

        Irrespectivly, I'd like to retract my angry tone, which was neither justified nor merited. Nobody likes to think that they're being treated like a petulant child, least of all if they're acting like one. If it's at all illuminating, this is pretty well my first effort at Perl coding, ever, and it is being debugged in the spare time I have while converting the aforementioned SGML files to a CSS-HTML format, the which is scarce. So I used up the project time I alloted myself for writing this thing, and am trying to steal time here and there to fix it. (Which is not conducive to the careful reading of documentation.)