Parameter query!

Clooney, David david.clooney at bankofamerica.com
Tue Aug 21 15:12:37 BST 2007


Thanks Edmond

More syntax to learn, however wouldn't want to be old fashioned :-)

Cheers, guess I better get cracking 

Dave

-----Original Message-----
From: london.pm-bounces at london.pm.org
[mailto:london.pm-bounces at london.pm.org] On Behalf Of Edmund von der
Burg
Sent: 21 August 2007 14:03
To: London.pm Perl M[ou]ngers
Subject: Re: Parameter query!

Hello,

and welcome to the list. Some general comments:

You should add 'use strict' and use warnings' to the top of your
script. These will make Perl slightly less flexible and complain more
about dodgy things in your code. Although annoying at first they will
make it easier for you in the long run.

You might want to use perltidy to tidy up your code so that it is
easier to read. To install it you may need to do 'cpan Perl::Tidy'.
Run it with 'perltidy -b your_script.pl'.

The way that you are using CGI.pm is entirely correct, but a bit
outdated. You might want to look into using a module like Template to
seperate your code and the actual layout. The site http://www.tt2.org
is very helpful.

Now others will actually answer the questions you asked :)


On 21/08/07, Clooney, David <david.clooney at bankofamerica.com> wrote:
> Hi all
>
>
>
> I joined this list a while back and was warned that everything other
> than perl is discussed, however I thought I would attempt to extract
> some of the wealth of knowledge lying beneath the discussions of
> arbitrary affairs.
>
>
>
> Newbie to perl so Here goes and don't laugh at my code, ok go on then.
>
>
>
> Using CGI.pm
>
>
>
> I am trying to pass all the values of a checkbox group to a subroutine
> but failing miserably.
>
>
>
> The subroutine below generates a form with all files/directories
found,
> based upon search criteria. all files are populated into the same
> checkbox group with different values. This all works fine, but passing
> the values to the next subroutine I having issues with.
>
>
>
> sub   spdm828a_technical_files_to_checkbox {
>
>            foreach $spdm828a_tech_file_list_part
> (@spdm828a_tech_file_list_part) {
>
>                         $spdm828a_tech_file_list_part =~ s/\s+$//;
>
>                         chop $spdm828a_tech_file_list_part;
>
>
>
>            if ( $spdm828a_tech_file_list_part =~ /\/$/) {
>
>                             print start_Tr({ -bgcolor => "#F0F8FF"}),
> start_td, 'Directory  ',end_td , start_td,
>
>
> checkbox_group(-name=>'spdm828a_tech_file_selection',
> -value=>"$spdm828a_tech_file_list_part"),
>
>                  br,
>
>                  end_td, end_Tr;
>
>                          }
>
>            else {
>
>            print start_Tr({ -bgcolor => "#FFFFFF" }), start_td,
> 'File',end_td , start_td,
>
>
checkbox_group(-name=>'spdm828a_tech_file_selection',
> -value=>"$spdm828a_tech_file_list_part"),
>
>
>
>                    br,
>
>                  end_td, end_Tr;
>
>
>
>                          }
>
>
>
>       }
>
> }
>
>
>
> What I don't get is that when I print
> (param('spdm828a_tech_file_selection')) below, all the selections from
> the previous form are concatenated into one long string, this is fine
,
> but if I declare the parameter into a string i.e $file_select and then
> print it I only get the first option selected from the checkbox group
> from the previous form.
>
>
>
> sub sub_technical_create_mail {
>
>     $file_select = (param('spdm828a_tech_file_selection'));
>
>     if ($file_select) {
>
>
>
>  print start_html(-title=>'NCG UK Restore
> Portal',-style=>{'src'=>"$style"}),
>
>       h1({-align=>'center'},'NCG UK Restore portal'),
>
>       h3({-align=>'center'},'NCG Restore Submit Selection');
>
>       print start_form,
>
>       pre,
>
>                  'Please confirm the selection you have made in order
> for the request to be Carried out',
>
>       "\n",
>
>       p;
>
> print p;
>
>       print "$file_select\n";
>
>       print (param('spdm828a_tech_file_selection')),"\n";
>
>       print "\n";
>
>       print "end\n";
>
> print       br,
>
>       submit(-name=>'Submit_final'),
>
>       end_form;
>
>      }
>
>     else {
>
>  print start_html(-title=>'NCG UK Restore
> Portal',-style=>{'src'=>"$style"}),
>
>       h1({-align=>'center'},'NCG UK Restore portal'),
>
>       h3({-align=>'center'},'NCG Restore Submit Selection');
>
>       print start_form,
>
>       pre,
>
>                  'You have not selected any data to be restored',
>
>       "\n",
>
>       ;
>
>      }
>
> }
>
>
>
> Any ideas on how I can get each checkbox group selection onto a new
line
> in the second sub would be much appreciated.
>
>
>
> Dave
>
>
>
>
>
>
>
>
> Notice to recipient:
> The information in this internet e-mail and any attachments is
confidential and may be privileged. It is intended solely for the
addressee. If you are not the intended addressee please notify the
sender immediately by telephone. If you are not the intended recipient,
any disclosure, copying, distribution or any action taken or omitted to
be taken in reliance on it, is prohibited and may be unlawful.
>
> When addressed to external clients any opinions or advice contained in
this internet e-mail are subject to the terms and conditions expressed
in any applicable governing terms of business or client engagement
letter issued by the pertinent Bank of America group entity.
>
> If this email originates from the U.K. please note that Bank of
America, N.A., London Branch and Banc of America Securities Limited are
authorised and regulated by the Financial Services Authority.
>


-- 
In reality I'm evdb at ecclestoad.co.uk - http://ecclestoad.co.uk
Use Perl? Take the survey: http://perlsurvey.org/survey/



Notice to recipient:
The information in this internet e-mail and any attachments is confidential and may be privileged. It is intended solely for the addressee. If you are not the intended addressee please notify the sender immediately by telephone. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

When addressed to external clients any opinions or advice contained in this internet e-mail are subject to the terms and conditions expressed in any applicable governing terms of business or client engagement letter issued by the pertinent Bank of America group entity.

If this email originates from the U.K. please note that Bank of America, N.A., London Branch and Banc of America Securities Limited are authorised and regulated by the Financial Services Authority.


More information about the london.pm mailing list