Groins has asked for the wisdom of the Perl Monks concerning the following question:

Below is a question I'm trying to answer, but it's not making much sense. Particulary where it says "What variable type in Perl could you use, that would identify repeated jump destinations."??

Any insights would be appreciated.

QUESTION AS FOLLOWS

If you have ever used an Internet browser you may have come across links that don't go anywhere (broken links) which are extremely annoying.
Part of the challenge of making programs that put in hypertext links is ensuring the link the program puts in always has an associated destination or anchor. An associated problem is ensuring that jump destinations or anchors are unique. i.e. jump destinations are never repeated.

What variable type in Perl could you use, that would identify repeated jump destinations.

Write a subroutine that uses the above data type (you can assume the data type is a global variable), takes as input a jump destination and prints to STDOUT a warning message if it has already received the input jump destination. Below is a skeleton subroutine you should base your answer on:

sub CheckJumpDestination { my($jump_destination) = @_; if ( ) { } else { } }

Replies are listed 'Best First'.
Re: Test Question - Does it make sense?
by matija (Priest) on May 09, 2004 at 07:44 UTC
    Well, the question, IMHO, is badly written - I imagine a lot of people would be trying to wrap their mind about embeding some kind of perl code into the page or whatnot.

    What the question is asking (again IMHO) is for a routine that will get a series of destinations, remember which ones it has already seen, and return an appropriate value based on that.

      the most important part of the question (that relates to variable type in perl) is "...associated problem is ensuring that jump destinations or anchors are unique..." There's only one variable type that guarantees non-repeated html targets ---->>>> hash....i.e. html targets become hash keys. you do the rest of your homework...not going to give you code....learn something, by doing it.
        Thanks for the hint aquarium - just enough to get me on the right track, cheers.
        A reply falls below the community's threshold of quality. You may see it by logging in.
        That's not a hint, that's an answer.

      At first I thought, "What does broken link detection have to do with uniqueness of destinations?" The answer: nothing. Just a typical homework question from a rambling professor.

      I reread the question, eliminating the first two useless sentences. Then it hit me: the answer was there the whole time:

      An associated problem is ensuring that jump destinations or anchors are unique....

Re: Test Question - Does it make sense?
by tilly (Archbishop) on May 09, 2004 at 07:40 UTC
    We've had lots of homework questions, but you may be the first who is asking a question from a take-home exam!
Re: Test Question - Does it make sense?
by dragonchild (Archbishop) on May 09, 2004 at 18:06 UTC
    Heck, if you're creative, you can provide answers to this using scalars, arrays, and hashes. Personally, I would use a CPAN module that provides an interface to a set. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested