Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

img function in GGI.pm

by kosta (Sexton)
on Feb 09, 2011 at 16:12 UTC ( [id://887233]=perlquestion: print w/replies, xml ) Need Help??

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

Hi I am using a CGI.pm to generate some html output
td(img({-src=>'/css/ico/notepencil32.png', -alt=>'ahoj', -height=>'23 +', -width=>'23' -id=>'myid'})) ])),

But I just cant get it to accept the id for the image It comes out like this
<img height="23" src="/css/ico/notepencil32.png" myid width="23"/>
Whats the problem? Why cant I assign the id attribute?

Replies are listed 'Best First'.
Re: img function in CGI.pm
by Anonyrnous Monk (Hermit) on Feb 09, 2011 at 17:01 UTC
    td(img({-src=>'/css/ico/notepencil32.png', -alt=>'ahoj', -height=>'23' +, -width=>'23' -id=>'myid'})) + ^

    You omitted the comma (so you're subtracting 'id' from 23...).

    With warnings on, you'd have gotten "Argument "id" isn't numeric in subtraction (-) at ..."

    Update: ...and this is for the downvoter, who was apparently too lazy to test himself:

    $ perl -wMCGI=:standard -le"print img({-src=>'/css/ico/notepencil32.pn +g', -alt=>'ahoj', -height=>'23', -width=>'23', -id=>'myid'})" <img height="23" src="/css/ico/notepencil32.png" id="myid" width="23" +alt="ahoj" />
      oh gosh oh gosh! It is always the little things that get me. Always! In some ways I love vim, I hate it in others (would have never happened with eclipse)

        It would have been obvious with better layout in emacs with any perl mode too because the indentation breaks. I suspect vim has similar behavior. So just changing to shorter, more legible line widths will help on a couple of levels-

        img({ -src=>'/css/ico/notepencil32.png', -alt=>'ahoj', -height=>'23', -width=>'23' -id=>'myid'})

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://887233]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-03-18 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (56 votes). Check out past polls.