in reply to Re: Re: Use your brain before trying to use mine!
in thread passing parameters??

common mann...if i would have got what i wanted, i wouldn't ask a question here? can u tell me how i would i convert that href ..name and value query string to normal staring, since the code is now on the local machine. I am not passing the values in name and values pair.
sub printAccessLog { &PrintContract; if ($totalEntries != 0) { print RSCrpt "Log Stats for $startMonth/$startDay/$longStartYe +ar to $endMonth/$endDay/$longEndYear\n"; print RSCrpt "TESTING = " . $startMonth . $startDay . longStartYea +r . "\n"; print RSCrpt "Average CGI response time by page name:\n"; print RSCrpt "\n"; # print "<TR><TD ALIGN=\"left\"><U>Page Name</U></TD><TD ALIGN= +\"center\"><U>Average Response Time<BR>in seconds</U></TD><TD ALIGN=\ +"center\"><U>Page Accesses</U></TD></TR>\n"; print RSCrpt "Page Name Page Accesses\n"; # sub avgrsp_pg_by_value {$avgRspTimePg{$b} <=> $avgRspTimePg{$ +a} } # @keypg = sort avgrsp_pg_by_value keys(%avgRspTimePg); sub avgrsp_pg_by_value {$pageCount{$b} <=> $pageCount{$a} } @keypg = sort avgrsp_pg_by_value keys(%pageCount); foreach(@keypg) { $prevValue = $contract_number; # printf "<TR><TD ALIGN=\"left\"><A HREF=\"$cgi\?contract_n +umber=$prevValue&member_id=$memberID&start_date=$startMonth$startDay$ +longStartYear&end_date=$endMonth$endDay$longEndYear&search_page=%s\"> +%s</A></TD><TD ALIGN=\"center\">%-23.3f</TD><TD ALIGN=\"center\">%s</ +TD></TR>\n", $_, $_, $avgRspTimePg{$_}, $pageCount{$_}; printf RSCrpt "<TR><TD ALIGN=\"left\"><A HREF=\"$cgi\?cont +ract_number=$prevValue&member_id=$memberID&start_date=$startMonth$sta +rtDay$longStartYear&end_date=$endMonth$endDay$longEndYear&search_page +=%s\">%s</A></TD><TD COLSPAN=\"2\" ALIGN=\"center\">%s</TD></TR>\n", +$_, $_, $pageCount{$_}; } print RSCrpt "<TR><TD COLSPAN=\"3\">&nbsp;</TD></TR>\n"; # $avgRspTimeFile = $totalRspTime / $totalEntries; # printf "<TR><TD COLSPAN=\"3\" ALIGN=\"left\">Average CGI resp +onse time = %.3f</TD></TR>\n", $avgRspTimeFile; printf RSCrpt "Total Mainframe Calls = %s\n", $mfcalls; if (!$memberBoolean) { @IDs = keys(%uniqueIds); $length = @IDs; printf RSCrpt "Total Unique IDs = %s\n", $length; } # print RSCrpt "</TABLE>\n"; } else { print RSCrpt "TESTING = total_entries = " . $totalEntries . "\n"; return 0; } print RSCrpt "TESTING != total_entries = " . $totalEntries . "\n"; + return 1; }

Replies are listed 'Best First'.
Re: Re: Re: Re: Use your brain before trying to use mine!
by dragonchild (Archbishop) on Aug 22, 2001 at 21:04 UTC
    I have no idea what you're asking, Anon. What do you mean by can u tell me how i would i convert that href ..name and value query string to normal staring? A few comments about what you're doing, though.
    1. Use CGI.pm - it will make your life SOOO much easier (and your script easier to read). You might have to redirect STDOUT, either within the script or on the commandline. But, that's trivial.
    2. PASS VARIABLES AROUND!! If you're calling a function, make that function completely uncoupled from your caller. You've got variables global to the function (if not global to the script!) wandering around and any of those could be compromised.
    3. If you're not already doing so, use strict and warnings. You will find a number of bugs that way. I guarantee it.
    4. Pick a consistent formatting system and stick with it. Use one that lays out your logical structure in a consistent manner.
    5. Allow your strings to go across newlines. For example, the two snippets below are equivalent to the compiler, but the second is sooo much easier to read.
      printf RSCrpt "<TR><TD ALIGN=\"left\"><A HREF=\"$cgi\?contract_number= +$prevValue&member_id=$memberID&start_date=$startMonth$startDay$longSt +artYear&end_date=$endMonth$endDay$longEndYear&search_page=%s\">%s</A> +</TD><TD COLSPAN=\"2\" ALIGN=\"center\">%s</TD></TR>\n", $_, $_, $pag +eCount{$_}; print RSCrpt '<TR><TD ALIGN="left">' . '<A HREF="' . $cgi . '?' . 'contract_number=' . $prevValue . '&member_id=' . $memberID . '&start_date=' . $startMonth$startDay$longStartYear '&end_date=' . $endMonth$endDay$longEndYear . '&search_page=' . $_ . '">' . $_ . '</A>' . '</TD><TD COLSPAN="2" ALIGN="center">' . "$pageCount{$_}</TD></TR>\n";
      That way, you have all of your &foo=bar stuff lined up and easily read. In addition, each of those prints should be in a function of their own. There is a lot of debate on when you should create a function. My rules of thumb go something like:
      1. If I use it twice, it's a function.
      2. Even if I only use it once, if it's complex and hinders readability, it's a function.
    6. And, most importantly, if you're asking for help, break the problem down to its smallest form and ask for help on that, in a general sense. I'm not going to fix your exact script (especially in its unreadable form), but I will gladly help you if you can explain what the general form of your problem is.

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!