I've just written my first module, and (predictably) it's causing me some problems. When I execute the script which calls the module, I get the following:

Can't find string terminator "`" anywhere before EOF at /usr/local/lib/perl/5.6.1/BuildLink.pm line 59.
Compilation failed in require at ./test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.

I'm just playing with some code and trying out some new things, so please don't expect the following code to be nirvana.

Here's the script which calls the module:

#!/usr/bin/perl -w use strict; use BuildLink; my $file = "/www/htdocs/shock/history.php"; my @words = buildLinks($file); print @words;

Not much to that. Here's the module:

package BuildLink; use strict; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(&buildLinks); %EXPORT_TAGS = ( DEFAULT => [qw(&buildLinks)]); my @linkedFile = buildLinks(@_); return @linkedFile; sub buildLinks { my $FileName = shift; my @wordList = bustFile($FileName); } sub bustFile { my $FileName = shift; open(IN, "$FileName") || die "Cannot open $FileName: $!\n"; my @text = do {local $/; <IN> }; @pieces = split_text(@text); @pieces = check_links(@pieces); return @pieces; } sub split_text { $_[0] =~ /("[^"]*"|[^\s"]+)/g; $_[0] =~ s/\.$//g; $_[0] =~ s/^\.//g; $_[0] =~ s/\s$//g; $_[0] =~ s/^\s//g; } sub check_links { my @pieces = @_; my @list; open(WORDLIST,"/www/htdocs/data/linklist.txt") || die "Cannot open /www/htdocs/data/linklist.txt: $!\n"; foreach my $word (@pieces){ open(WORDLIST,"/www/htdocs/data/linklist.txt") || die "Cannot open /www/htdocs/data/linklist.txt: $!\ +n"; my ($checkLine, $checkWord, $checkLink); while ($checkLine = <WORDLIST>) { ($checkWord, $checkLink) = split(/\t/, $checkLine); if ($word eq $checkWord) { $word = "<a href=\"$checkLink\">$word</a>";` } push @list, $word; last if ($checkWord gt $word); } close WORDLIST; } return @list; } 1;

Any thoughts on how to correct this error would be great. Thanks!

If things get any worse, I'll have to ask you to stop helping me.


In reply to Can't find string terminator by shockme

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.