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

I need to figure out how to create a shortcut into a dynamically generated help file for 3 different products. I figure this is kind of what I need to accomplish this. 1) Setup 3 hashes to store the topics and the values for each product. 2) Readin and store the topic value from the query string 3) compare the query string topic value with the keys in each hash to find the correct topic, then pull the corresponding value for that topic out of the hash. 4)finally display the correct topic to the end user by substituting my result above with variable startpoint which sets what help topic to start with and here is my problem how do I pass the value of target(my help topic I want to pass into the sub tHelp?) my attempt to create a hash, seems like it should have worked but if I just try to write out the values the hash should contain I get nothing at all in my browser window..odd. 2) If I set variable $topic = to the topic value in the query string this should set me up to do my comparison with the keys in the hash not sure how to accomplish the comparison.. could use an example on how to do something like this.
<% use Win32::OLE; #use strict; #use warnings; my $User = $Request->item("Login")->item(); my $Site = $Request->item("Site")->item(); #my $topic= $Request->item("Topic")->item(); my $Referer = $Request->ServerVariables("HTTP_REFERER")->item(); my $topic = $Request->ServerVariables->{'QUERY_STRING'}->item("Top +ic"); my %topics = ( home => 'TEMPO%205%20Help%20Topics-01-1.html', listingmgr => 'TEMPO%205%20Help%20Topics-06-1.html', cma => 'TEMPO%205%20Help%20Topics-11-1.html', hotsheetmgr => 'TEMPO%205%20Help%20Topics-10-1.html', clientmgr => 'TEMPO%205%20Help%20Topics-05-1.html', tempofinancials => 'TEMPO%205%20Help%20Topics-14-1.html', tools => 'TEMPO%205%20Help%20Topics-18-1.html', rep => 'TEMPO%205%20Help%20Topics-12-01.html', taxmgr => 'TEMPO%205%20Help%20Topics-13-1.html', TempoMemberInfo => 'TEMPO%205%20Help%20Topics-19-1.html', email => 'TEMPO%205%20Help%20Topics-09-1.html', ); if (!defined($topic)) { } my $startpoint = $topics{$topic}; if (!defined($startpoint)) { exit(); } return $startpoint;
help subroutine.
sub tHelp(\$topics) if ($Session->{'usrType'} eq 'Std') { if ($Request->ServerVariables("SERVER_NAME")->item()=~/tempohelp/i +) { my $startpoint=$topics($topic);'Content/HELP/TPO/default/Tempo_ +help-08-1.html'; my $target='Tempo%20help_frame'; $str .= shadowBox("Tempo Help", qq^<help_iframe name="$target" +startpoint="$startpoint"/>^ , ($g_docWidth/5*4-(2*$g_docSpace))); return $str; } }

Replies are listed 'Best First'.
Re: linking into dynamically generated file passing hash value
by shmem (Chancellor) on Nov 08, 2007 at 09:06 UTC
    If I just do response->redirect to my desired help content it doesn't work because the help content has not yet been generated this is odd as it does not function that way for other tabs from the database until I click on the help tab i must somehow generate that click request making help tab active does not do it.

    I tried hard to parse that, but can't figure out what you are trying to say.

    Your subroutine is odd. $topics as a subroutine prototype? I guess you mean

    sub tHelp { my $topics = shift; ...

    Looking at that snippet

    my $startpoint=$topics($topic);'Content/HELP/TPO/default/Tempo_ +help-08-1.html';

    I have to ask - what is $topics? a subroutine reference? Then you have to write

    my $startpoint=$topics->($topic);

    Also, what do you have that string literal in void context for? What is in $topic? where does it come from? Can't see it anywhere else in that sub.

    Please reformulate your question and post code which at least compiles, and enough info to avoid wild guesses. See I know what I mean. Why don't you?

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}