Hi, I have been given 6 questions to research as part of my studies and I have answered 4 out of the 6 but I am struggling with the two questions below. I am only a junior at Perl and really am struggling. Please help.

[1]   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 ( # Your code here ) { # Your code here. } else { # Your code here. } }
[2]    What will the following subroutine return (DoSomething) given the input value below:
%unreported_case_list = ( '30/11/90, cp654/88' => '1' ); &DoSomething('In <FD:"Case Title">Bradburn v Harris</FD:"Case Title"> +<FD:"Case Citation">30/11/90, Fisher J, HC Auckland CP654/88</FD:"cas +e Citation"> Fisher J was dealing with a counterclaim for interest un +der two vendor mortgages.'); sub DoSomething { my($line) = @_; my($new_line, $citation, $start_of_line, $jump_destination) = ('','','','',''); DEBUG('c',"IN DoSomething\n"); while ( $line =~ s{^ ( .*? ) < FD:"Case \s Citation" > ( .+? ) </ +FD:"Case \s Citation" > }{}xi ) { $start_of_line = $1; $citation = &StripWhiteSpace($2); if ( $citation !~ m{ \b tclr \b }xi ) { $jump_destination = lc($citation); if ( exists($unreported_case_list{$jump_destination}) ) { $new_line .= "$start_of_line<FD:\"Case Citation\"><JL: +\"Internal Jump\",\"$jump_destination\">$citation</JL></FD:\"Case Cit +ation\">"; $unreported_jl_count++; } elsif ( $citation =~ m{ ( \d{1,2} / \d{1,2} / \d{4} | \d{2 +} ) , .+? ( [a-z]+\d+ (?: / \d+ )? ) }xi ) { $jump_destination = &NormaliseDate("$1").', '.lc($2); if ( exists($unreported_case_list{$jump_destination} +) ) { $new_line .= "$start_of_line<FD:\"Case Citation\"> +<JL:\"Internal Jump\",\"$jump_destination\">$citation</JL></FD:\"Case + Citation\">"; $unreported_jl_count++; } else { $new_line .= "$start_of_line<FD:\"Case Citation\"> +$citation</FD:\"Case Citation\">"; } } else { $new_line .= "$start_of_line<FD:\"Case Citation\">$cit +ation</FD:\"Case Citation\">"; } } else { $new_line .= "$start_of_line<FD:\"Case Citation\">$citatio +n</FD:\"Case Citation\">"; } } $new_line .= $line; DEBUG('c',"LEAVING DoSomething\n"); return($new_line); } #-------------------------------NormaliseDate------------------------- +---- # INPUT # $date # # RETURNS # normalised date # # Normalises the input date to dd/dd/dddd format. #--------------------------------------------------------------------- +---- sub NormaliseDate { my($date) = @_; my($day, $year, $month) = (0,0,0); DEBUG('c',"IN NormaliseDate\n"); if ( $date =~ m{^ ( \d{1,2} ) / ( \d{1,2} ) / ( \d{4} | \d{2} ) $} +x ) { $day = $1; $month = $2; $year = $3; if ( length($day) == 1 ) { $day = '0'.$day; } if ( length($month) == 1 ) { $month = '0'.$month; } if ( length($year) == 2 ) { $year = '19'.$year; } } DEBUG('c',"LEAVING NormaliseDate\n"); return("$day/$month/$year"); } #-----------------------------StripWhiteSapce------------------------- +---- # INPUT # $line # # RETURNS # $line # # Removes leading and trailing whitespace from the input string. #--------------------------------------------------------------------- +---- sub StripWhiteSapce { my($line) = @_; DEBUG('c',"IN StripWhiteSapce \n"); $line =~ s{^ \s+ }{}x; $line =~ s{ \s+ $}{}x; DEBUG('c',"LEAVING StripWhiteSapce \n"); return($line); }

update (broquaint): added formatting
update 2 (broquaint): title change (was Perl Newbe Urgently Needs Help)


In reply to Perl junior entreats monastery for course help by spyder78

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.