Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
The stupid question is the question not asked
 
PerlMonks  

Can't find string terminator

by shockme (Chaplain)
on Mar 24, 2002 at 23:53 UTC ( [id://154024]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

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.

Replies are listed 'Best First'.
Re: Can't find string terminator
by BeernuT (Pilgrim) on Mar 25, 2002 at 00:00 UTC
    if ($word eq $checkWord) { $word = "<a href=\"$checkLink\">$word</a>";` <--- }
    should be
    if ($word eq $checkWord) { $word = "<a href-\"$checkLink\">$word</a>"; }
    better yet
    if ($word eq $checkWord) { $word = qq{<a href="$checkLink">$word</a>}; }
    You also opened WORDLIST twice in your &check_links sub, 1 before you looped through @pieces and then you on each iteration of @pieces.

    Also your perl -c complained about @pieces being global when i checked it against your mod.

    -bn
      Oh, for crying out loud . . . maybe my wife is right and I should go to bed . . . thanks!

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

(Ovid) Re: Can't find string terminator
by Ovid (Cardinal) on Mar 25, 2002 at 00:06 UTC

    Update: aargh! Late again :)

    In &check_links, you'll see the following line of code:

    $word = "<a href=\"$checkLink\">$word</a>";`

    No doubt you're wondering about that single quote after the semicolon :)

    By the way, you also forgot to declare @pieces.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://154024]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.