Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Passing Parameters via hyperlink

by o2bwise (Scribe)
on Jun 26, 2013 at 22:18 UTC ( #1040858=perlquestion: print w/ replies, xml ) Need Help??
o2bwise has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I am new to using the Mojolicious Perl mod and pretty new doing web design and I am positively stumped trying to pass parameters within a hyperlink. I would rather use the Mojolicious url_for command, but am fine specifying the hyperlink without.

Let's say there are variables $x and $y. Hyperlink text is value for $x.

One of my url_for attempts (although I see I am not encapsulating the href value in quotes:

<a href= <%= url_for("foo")%><%= x=$x&y=$y> %>$x</a>

And here is an attempt without url_for:

<%= <a href="$x&y=$y">%><%= $x %></a>

Actually, in one of my attempts (here just trying to pass one variable), I get to the url I want and I think the text of the url shows the correct syntax for passing a variable, but I do not see it. This is less generic, but:

<tr><td><a href="<%= +$id %>"><%= $id %></a></td></tr>

Here is the url it goes to:

(Looks good to me!) And I have this asking for the parameter:

% use Data::Dumper; % use CGI; % my $cgi = new CGI; % my %input = $cgi->param(); % layout 'default'; % my $dir = '/home/tony/outage-management/testing'; % open (TEST,">$dir/device_list_test.txt"); % print TEST '%input: ', Dumper(%input);

And file device_list_test.txt contains


(The hash is empty.) Maybe I am passing the variable, but I am doing something wrong at the place where I try to fetch it?

For all I know, I am trying to do something in ways that cannot be done. Would sure appreciate a hand.



Comment on Passing Parameters via hyperlink
Select or Download Code
Replies are listed 'Best First'.
Re: Passing Parameters via hyperlink
by davido (Archbishop) on Jun 27, 2013 at 00:01 UTC

      C'mon Dave, help me out! ;-)

      Like I said, I am just learning. Other folks at work recommended I use Mojolicious with bootstrap.


        Like I said, I am just learning. Other folks at work recommended I use Mojolicious with bootstrap.

        Well, you're already using Mojo, so  $mojoself->req->params->to_hash

Re: Passing Parameters via hyperlink
by sundialsvc4 (Abbot) on Jun 26, 2013 at 23:37 UTC

    My first glance, when compared against this documentation page for, is that you need to use an array not a hash here.

    Now, what this has to do with Mojolicious, I don’t know...

    Also, check the usual suspects:   use a client-side debugger to verify what the URL string actually contains (“trust, but verify ...”), and likewise what CGI thinks it received.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1040858]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-10-08 17:14 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (222 votes), past polls