in reply to Param and Scalars

First, when you post code, make sure you encase it in PM's special <CODE> & </CODE> tags, which will format everything nicely and remove problems with special HTML characters.

As to your specific problem, remember that strings with single quotes do NOT get interpolated, that is, your $temp_name variable will not be expanded, and perl will treat the string as "$temp_name". Either you want to use no quotes, which will include the value of the variable directly, or use double quotes, which will expand any variables it can in addition to other text that you have. This is probable why most of your code isn't working.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: Param and Scalars
by Laila (Initiate) on Mar 28, 2001 at 08:19 UTC
    Sorry about that. Here are the two snippets of code with the appropriate tags around them?

    The param stuff:

    if (! param ) { show_form(); } elsif (defined param ('file_chosen)) { parse_text(); } elsif (defined param('$temp_name')) {print print_results(); }
    The radio button group:
    while ($counter<=$#doc_offset_array) { @temp_array = @{$array_of_arrays[$counter]}; $temp_name =$doc_offset_array[$counter]; foreach $i (@temp_array) { print radio_group(-name=>'$temp_name', -values=>[@temp_array], -linebreak=>'true'); } } }

    Actually, using no quotes in both the radio group and the param function still prevents the elsif statement from being executed, though the radio buttons print OK. Using double quotes in both sets of code also prints radio buttons OK, but prevents the elsif statement from being executed. L

      It looks like you haven't cut-and-pasted - for example, you should have

      .. elsif (defined param ('file_chosen'))

      .. but obviously, you don't, otherwise it probably wouldn't even parse. The other one ought to be something like

       elsif (defined param ("$temp_name"))

      (personally, I prefer double quotes, most don't.)

      I think you ought to try and post the actual code, rather than a pseudocode example, as there are lots of other things wrong with this which look more like someone trying to express what they want to do rather than the code they already have.