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

How do I create a link from my image which is in my webpage using CGI ? print $cgi->img({-src=>'http://localhost/MyImage.jpg', -alt=>'ahoj', -height=>'300', -width=>'250', -align=> 'middle', -id=>'myid'}); I'm wondering if I could pass href as an additional parameter for it to create a link.I tried but did not succeed.Please help.

Replies are listed 'Best First'.
Re: create link from my image
by Corion (Patriarch) on May 07, 2011 at 07:36 UTC

    What is the HTML you want to create?

    What HTML does your current code create?

    Have you looked at the CGI.pm documentation and looked for "href"?

    Personally, I find it easier to just print the HTML I want, potentially using one of the Template systems.

Re: create link from my image
by John M. Dlugosz (Monsignor) on May 07, 2011 at 09:07 UTC
    Why did you post such an unreadable mess? Did you not notice in the Preview that you didn't know how to format code or even paragraphs, and try correcting it?

    Sorry for admonishing you in public, but you didn't Log In so you are Anonymous.

    I for one really wonder about the programming ability of anyone who doesn't notice the sentences right after the message submission blank, or notice what's going on in the Preview. Like, maybe you treat documentation and warnings the same way…

      of anyone who doesn't notice the sentences right after the message submission blank

      Hi, different Anonymous here :)

      FWIW, they're real easy to miss, and the bolded text only appears after a form; after you hit preview it disappears.

      Here is how i would change

      current
      Title: [Re^2: create link from my image]
      Your "PerlMonks-approved HTML"-formatted text:
      You can use these tags: <p> — for text; <code> — for code

       

       

       

      [preview] [create]

       

      better
      Title: [Re^2: create link from my image]
      Use <p> text here </p> and <code> code here </code>
      to format your question, its "PerlMonks-approved HTML":

       

       

       

      [preview] [create]

        That's what I'm trying to introduce too. I have the Javascript formatting toolbar for perlmonks enabled on my own account. It's hard to miss for a newbie because it's just above the textarea, yet it isn't too obtrusive. The gods don't like it much, so it's not the default though.

        True. But even if you didn't notice it, you might hunt around for instructions after seeing the preview.