Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recursion help

Status
Not open for further replies.

serpentsix

Programmer
Nov 23, 2002
2
US
I am a Perl newbie, and new to these forums as well. I have a program that should do the following:

ask for the name of a text file that contains html code
process the tags, including some tags with text file names
open up the tags with text file names and process those
so on and so forth

I have that part running just great. I need to have it break out of the loop though, as it currently runs forever. How can I compare the read-in text file name to the text file name that is/has been already processed.

Thanks
 
This is not very easy to answer with out a better idea of how you are implementing the file parser (i.e. what does the code look like?). I can, however, speculate that for a given text file you are probably looping over the tags in the file (hopefully using some module like HTML::parser to parse the tags). Therefore you can store the current value of the textfile in a variable and check it against any textfile that you come across in the document. You can skip processing if a comparison of the two values reveals that they are equal.
pseudocode:
Code:
TAG:
foreach $tag (@htmltags) {

    if ($tag->{'type'} eq 'textfile') {
 
        next TAG if $tag->{'value'} eq $curfile;
        process_textfile($tag->{'value'});
    }
    ...
}
something like that.

jaa
 
I am not using HTML:parser, doing this all manually.

I understand your reply for the most part, but I think I need to step back one step. How do you call the current file? Will I have to store it in it's own variable and then compare, or is there a built-in feature in Perl that could accomplish that like $_[0]?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top