Re: Labelling Radio Group Values

2011-01-12 Thread Shlomi Fish
Hi Stephen,

a few comments on your code:

On Tuesday 11 Jan 2011 17:44:32 Stephen Allen wrote:
 I have sucessfully created as Radio-group along the lines of
 
 @TiesArray = SSDArray($uniqueorgref);

Add:

{{{
use strict; 
use warnings;
}}}

to the start of your script. Then declare all variables using my:

http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings

 if (@TiesArray[0] ne ) {
 
 @TiesDesc = SSDDescArray($uniqueorgref);

You should indent properly. See:

http://perl-begin.org/tutorials/bad-elements/#no-indentation


 %TiesHash = @TiesDesc;

Are you sure you want to initialise a hash from an array this way?

 $q = new CGI;

Avoid indirect object notation:

http://perl-begin.org/tutorials/bad-elements/#indirect-object-notation

And you should call the CGI object with a more meaningful name  than $q.

 print $q-start_form(-method=POST,
 -action=http://../cgi-bin/ViewQuote.pl;),
 $q-p(The system has identified  etc and click the SEND
 button.),
 $q-hidden(uniqueorgref, $uniqueorgref),
 $q-radio_group(-name=hideordNo, -values=\...@tiesarray, -
 linebreak=true, -labels=\%TiesHash),
 $q-submit(Send),
 $q-hr,
 $q-end_form;

I don't like CGI.pm's HTML generation methods too much (they are bloat if you  
ask me). A templating system such as the Template Toolkit will be better:

http://perl-begin.org/uses/text-generation/

 }
 
 
 My problem is that the hash that describes the radio group values -
 %TiesHash - (and should replace them on screen) is not operating. Any
 thoughts?

You can try using a debugger to see where it goes wrong:

http://perl-begin.org/topics/debugging/

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Public Domain Photos - http://www.flickr.com/photos/shlomif/

Chuck Norris can make the statement This statement is false a true one.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Labelling Radio Group Values

2011-01-12 Thread John W. Krahn

Stephen Allen wrote:

I have sucessfully created as Radio-group along the lines of

@TiesArray = SSDArray($uniqueorgref);
if (@TiesArray[0] ne ) {


You are testing a list against a scalar value, but fortunately your list 
has only one element.  If you had warnings enabled then perl would have 
told you to use a scalar instead of a list:


if ( $TiesArray[ 0 ] ne  ) {

And why are you comparing $TiesArray[ 0 ] to an empty string?  Will 
$TiesArray[ 0 ] always contain a valid string?  Or are you trying to 
determine if @TiesArray has any elements at all?




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Labelling Radio Group Values

2011-01-12 Thread Stephen Allen
Hi Shlomi

Thanks for your comments.

In fact, the problem was enirely my own fault  and did not exihibit in
the code I published.

More specifically the hash I created in %TiesHash did not use the
correct Key - hence it didn't work.

Get that right and the rest falls into place nicely.

Stephen




On Jan 12, 9:44 am, shlo...@iglu.org.il (Shlomi Fish) wrote:
 Hi Stephen,

 a few comments on your code:

 On Tuesday 11 Jan 2011 17:44:32 Stephen Allen wrote:

  I have sucessfully created as Radio-group along the lines of

  @TiesArray = SSDArray($uniqueorgref);

 Add:

 {{{
 use strict;
 use warnings;

 }}}

 to the start of your script. Then declare all variables using my:

 http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings

  if (@TiesArray[0] ne ) {

  @TiesDesc = SSDDescArray($uniqueorgref);

 You should indent properly. See:

 http://perl-begin.org/tutorials/bad-elements/#no-indentation

  %TiesHash = @TiesDesc;

 Are you sure you want to initialise a hash from an array this way?

  $q = new CGI;

 Avoid indirect object notation:

 http://perl-begin.org/tutorials/bad-elements/#indirect-object-notation

 And you should call the CGI object with a more meaningful name  than $q.

  print      $q-start_form(-method=POST,
  -action=http://../cgi-bin/ViewQuote.pl;),
  $q-p(The system has identified  etc and click the SEND
  button.),
  $q-hidden(uniqueorgref, $uniqueorgref),
  $q-radio_group(-name=hideordNo, -values=\...@tiesarray, -
  linebreak=true, -labels=\%TiesHash),
  $q-submit(Send),
  $q-hr,
  $q-end_form;

 I don't like CGI.pm's HTML generation methods too much (they are bloat if you 
  
 ask me). A templating system such as the Template Toolkit will be better:

 http://perl-begin.org/uses/text-generation/

  }

  My problem is that the hash that describes the radio group values -
  %TiesHash - (and should replace them on screen) is not operating. Any
  thoughts?

 You can try using a debugger to see where it goes wrong:

 http://perl-begin.org/topics/debugging/

 Regards,

         Shlomi Fish

 --
 -
 Shlomi Fish      http://www.shlomifish.org/
 My Public Domain Photos -http://www.flickr.com/photos/shlomif/

 Chuck Norris can make the statement This statement is false a true one.

 Please reply to list if it's a mailing list post -http://shlom.in/reply.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Labelling Radio Group Values

2011-01-12 Thread Dr.Ruud

On 2011-01-12 10:44, Shlomi Fish wrote:


Add:

{{{
use strict;
use warnings;
}}}

to the start of your script.


That adds 3 ENTERs and LEAVEs for no good reason. The code is not in a 
tight loop, so that doesn't matter much, but there is more:


perl -MData::Dumper -wle '
  $x = 1;
  {{{
use strict;
use warnings;
$y = 1;
  }}}
  $z = 1;
'
Global symbol $y requires explicit package name at -e line 6.
Execution of -e aborted due to compilation errors.

So both the $x and $z are missed, if you would adopt the silly {{{ ... 
}}} notation.


--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Labelling Radio Group Values

2011-01-12 Thread Uri Guttman
 R == Ruud  rvtol+use...@isolution.nl writes:

  R On 2011-01-12 10:44, Shlomi Fish wrote:
   Add:
   
   {{{
   use strict;
   use warnings;
   }}}
   
   to the start of your script.

  R That adds 3 ENTERs and LEAVEs for no good reason. The code is not in a
  R tight loop, so that doesn't matter much, but there is more:

  R perl -MData::Dumper -wle '
  R   $x = 1;
  R   {{{
  R use strict;
  R use warnings;
  R $y = 1;
  R   }}}
  R   $z = 1;
  R '
  R Global symbol $y requires explicit package name at -e line 6.
  R Execution of -e aborted due to compilation errors.

  R So both the $x and $z are missed, if you would adopt the silly {{{
  R ... }}} notation.

shlomi does that stupid {{{}}} thing to marks his code changes in
posts. does that too on the beginner's list. very moronic style.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/