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

Re^2: Trying to optimize de-referenced hash slice without scope variables...

by monsieur_champs (Curate)
on Jun 15, 2004 at 17:36 UTC ( [id://366967]=note: print w/replies, xml ) Need Help??


in reply to Re: Trying to optimize de-referenced hash slice without scope variables...
in thread Trying to optimize de-referenced hash slice without scope variables...

Interesting point. I use $data 8 times. Half as a boolean test (no de-reference) and half as a hash reference (to recover one or more values). I guess (and maybe I'm wrong about this) that it doesn't worth the benchmark...

Here is the complete function code:

sub inputBox{ # Don't uncomment, use @_ instead # my $action_url = shift; # $_[0] # my $msgid = shift; # $_[1] # my $action = shift; # $_[2] my $data = $_[3]; # oh, I needed this one, I wasn't able to use a ha +sh-slice from a hash-reference in one shot. <readmore> return qq{<form action="$_[0]" method="post">\n}. ($_[1]? qq{ <input type="hidden" name="message_id" value="$_[1]" />\n +}:''). qq{ <input type="hidden" name="action" value="$_[2]" /> <input type="hidden" name="commit" value="1" /> <table align="center" border="1" cellpadding="5" cellspacing="0"> <tr valign="middle" align="center" bgcolor="$color{TABLE_HEAD}"> <td colspan="2"> } .($_[2] eq 'edit'? "Edit Message #$_[1]" : 'Compose New Message' ). qq{ </td> </tr> <tr valign="middle" align="left" > <td> Author: </td> <td> }.( $_[2] eq 'edit'? q{ <input type="text" name="author" size=" +40" }. ( $data? qq{value="$data->{author}"} : &TWiki::Func::getWikiUserName +() ) . qq{ />} : &TWiki::Func::getWikiUserName() ) . q{ </td> </tr> <tr valign="middle" align="left"> <td>Due Date: </td> <td>} . &gen_date_selector( 'due', ( $data? @$data{'day','month' +,'year','hour','minute'} : (localtime)[5]+1900, (localtime)[4]+1, (lo +caltime)[3], 23, 59 ) ) . qq{ </td> </tr> <tr valign="middle" align="left"> <td>Message: </td> <td> <textarea rows="5" name="msg" cols="50">}.($data? $data->{msg} + : '' ).qq{</textarea> </td> </tr> <tr valign="middle" align="left"> <td> <input type="checkbox" name="dropped" value="Y" }.($data && $d +ata->{dropped} eq 'Y'? 'CHECKED':'' ).q{>&nbsp;Dropped. </td> <td align="right"> <input type="submit" name="change" value="Change Message"> </td> </tr> </table> </form> }; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found