Ok, I've got it down to one problem right now, I need an explicit 
package name for this:
foreach $key(keys %pages) {
        print "<a href=\"$pages{$key}\">$key</a>\n";
}

It says I need it for $key but no matter where I put the my it won't 
stop giving me that error.  Where in that does the my go?

> 
> 
> Kyle --
> 
> ...and then Kyle Babich said...
> % 
> % Ok, I decided to make my test.cgi into a kind of refernce page for 
when 
> % I'm creating my site.  There is some kind of problem with my hash.  
> % Once again can someone explain to me what I'm doing wrong?
> 
> As perl tells you, there are a few errors.
> 
> 
> % 
> % Here is what I got from doing perl -Tcw in the shell:
> % > bash-2.05$ perl -Tcw test.cgi
> % > bash-2.05$ Scalar found where operator expected at test.cgi line 
37, 
> % near "print
> % >  "$link's"
> % > >   (Might be a runaway multi-line "" string starting on line 36)
> % > >         (Do you need to predeclare print?)
> 
> This is, in fact, something like that; you have a " in front of 
foreach.
> 
> 
> % > > Bareword found where operator expected at test.cgi line 37, 
> % near "$link's page
> % > "
> % > >         (Missing operator before page?)
> % > > Global symbol "%pages" requires explicit package name at 
test.cgi 
> % line 32.
> % > > Global symbol "$link" requires explicit package name at 
test.cgi 
> % line 36.
> % > > syntax error at test.cgi line 37, near "print "$link's "
> 
> As a result, this follows.
> 
> 
> % > bash: Scalar: command not found
> % > bash-2.05$ Global symbol "%pages" requires explicit package name 
at 
> % test.cgi lin
> % > e 37.
> 
> Same thing here.  So everything can be traced back to one point, as 
far
> as I can tell :-)
> 
> 
> % 
> % Here is the source:
> ...
> % 
> % my $foreach = "foreach $link (links %pages) {
> %     print "$link's page:  $pages{$link}\n";
> % }";
> 
> Here ya go.  It looks like you're trying to save this foreach loop for
> later, probably to spit out the contents in your HTML, but your 
quoting
> gets messed up.  You have
> 
>   ... = "foreach ...
>     print " ... more garbage that perl sees as OUTSIDE the quotes
> 
> and so that won't work.
> 
> Usually I'd just say that you need to escape the inside quotes or use
> different quotes (perhaps qw@@ or the like) but that will simply give 
you
> the literal text of the foreach loop in your HTML output, which 
probably
> isn't what you want.
> 
> It's still early :-) and I don't see an elegant way of doing this 
through
> my pre-Cheerios fog.  You could, though, try something like
> 
>   my foreach = "" ;
>   foreach $link (keys %pages) # you meant this instead of (links %
pages), no?
>   {
>     foreach =. "$link's page: $pages{$link}\n"
>   }
> 
> to iterate through your links and add the text you want to a $foreach
> variable, which ou can then spit out later.  It feels like there 
should
> be a less clunky way, but other than breaking the HTML section into 
two
> or more here docs I don't see it.  Perhaps one of the other wizards 
will
> come up with something prettier :-)
> 
> 
> HTH & HAND
> 
> :-D
> -- 
> David T-G                      * It's easier to fight for one's 
principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune 
cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf 
Qrprapl Npg!
> 
> 
> 

-- 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to