Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Formatting variables

by Bod (Parson)
on Nov 29, 2020 at 13:46 UTC ( [id://11124366]=note: print w/replies, xml ) Need Help??


in reply to Re: Formatting variables
in thread Formatting variables

looks like a nested structure to me, TIMTOWTDI

These are actually HTML form element names, not Perl variables but they are dynamically generated by a Perl script like so:

$query=$dbh->prepare("SELECT idBusiness,emaillist,private,name,title,d +escription FROM Business ORDER BY metric"); $query->execute(); while (($id,$em,$private,$text,$title,$desc)=$query->fetchrow_array()) + { $list_color=$em?'black':'slategray'; ($chk, $sub, $crm, $warmth)=$dbh->selectrow_array("SELECT Business +_idBusiness, subscribe, CRMaccess, warmth FROM Business_has_Contact W +HERE Business_idBusiness = $id AND Contact_idContact = $data{'contact +'}"); if ($chk) { $check=' checked'; $dis=''; } else { $check=''; $dis=' disabled'; } $warmth = 0 unless $warmth; $crmr_chk = $crmw_chk = ''; $crmr_chk = ' checked' if $crm; $crmw_chk = ' checked' if $crm eq 'W'; $subscribe=$sub?' checked':''; $text="<i>$text</i> <span class=\"privatelist\">[private]</span>" +if $private; print "<tr>\n<td><input type=\"checkbox\" name=\"bus_$id\" onChang +e=\"subscribe(this,$id);\"$check>\n"; print "<input type=\"checkbox\" name=\"sub_$id\"$subscribe$dis></t +d>\n"; print "<td title=\"$title\" style=\"color:$list_color\">$text</td> +\n"; print "<td style=\"text-align:center\"><input type=\"checkbox\" na +me=\"crmr_$id\" onClick=\"crmAccess(this, $id);\"$crmr_chk>\n"; print "<input type=\"checkbox\" name=\"crmw_$id\" onClick=\"crmAcc +ess(this, $id);\"$crmw_chk></td>\n"; print "<td><img src=\"/images/site/warmth$warmth.png\" style=\"wid +th:28px\"> </td>\n" if $chk; print "</tr>"; }
This is part of a 4500+ line script that was originally written a long time ago and has been added to and modified lots over the years. Hence lack of white space and other poor legibility on some of the older bits of code. Nowadays I insert spaces either side of = and a space after a comma.

Replies are listed 'Best First'.
Re^3: Formatting variables
by LanX (Saint) on Nov 29, 2020 at 17:50 UTC
    Please don't be offended, but after looking at your code I'd really appreciate if you stopped complaining about the way this site was implemented.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Please don't be offended

      I'm not :)

      The bulk of that code sample was written somewhere between 8 and 10 years ago...perhaps I should really go back and tidy/improve it so that is closer to my current standards. I am sure current standards are nothing like the quality of many here but coding for me is a sideline - it is not my profession. I code partly for enjoyment but mostly to create tools for the company I run which has nothing to do with IT.

      I was once told that everyone should look back at code they wrote years ago and see something poor - that way they know they are making progress...kind of makes sense to me...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-25 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found