Loading ...
Sorry, an error occurred while loading the content.
 

Parameter

Expand Messages
  • Rafael Faria
    i now if i do sub something { my $variable = shift; prinot $variable; } i know that shift will get the first argument that i will pass... like
    Message 1 of 27 , Mar 21, 2001
      i now if i do

      sub something {
      my $variable = shift;
      prinot $variable;
      }

      i know that "shift" will get the first argument that i will pass...
      like

      &something("Testing");



      how can i change my sub to work like that
      &something("Testing",$id)

      and the sub get the second argument?

      thanks
      -rf
    • J.E. Cripps
      ... The arguments in the sub call are put in the pre-defined array @_. Take the 2nd one off just as you did the first. That s for simple scalar arguments.
      Message 2 of 27 , Mar 21, 2001
        > how can i change my sub to work like that
        > &something("Testing",$id)

        > and the sub get the second argument?

        The arguments in the sub call are put in the
        pre-defined array @_. Take the 2nd one off
        just as you did the first.

        That's for simple scalar arguments.
      • Rafael Faria
        ... but i will have to do sub something { ($variable1,$variable2) = @_; } ?? ... [ r a f a e l f a r i a] _____________________
        Message 3 of 27 , Mar 21, 2001
          > > how can i change my sub to work like that
          > > &something("Testing",$id)
          >
          > > and the sub get the second argument?

          but i will have to do

          sub something {
          ($variable1,$variable2) = @_;
          }
          ??




          >The arguments in the sub call are put in the
          >pre-defined array @_. Take the 2nd one off
          >just as you did the first.
          >
          >That's for simple scalar arguments.
          >
          >
          >
          >
          >
          >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

          ---

          [ r a f a e l f a r i a] _____________________
          _________________rafaelrfc@...
          WebMaster Universo Online - http://www.uol.com.br
          Phone # +55 11 3038-8665
        • Rafael Faria
          How can i make uppercase and lowercase of one word? something like $test = $uppercase( teste ); print $test; and it return TESTE
          Message 4 of 27 , Mar 21, 2001
            How can i make uppercase and lowercase of one word? something like

            $test = $uppercase("teste");
            print $test;

            and it return

            TESTE
          • Doug Wells
            You re exactly correct, although you can still use my for your variables, i.e. sub something { my ($variable1,$variable2) = @_; } Good luck, Doug ...
            Message 5 of 27 , Mar 21, 2001
              You're exactly correct, although you can still use
              "my" for your variables, i.e.

              sub something {
              my ($variable1,$variable2) = @_;
              }

              Good luck,
              Doug



              --- Rafael Faria <rafaelrfc@...> wrote:
              >
              > > > how can i change my sub to work like that
              > > > &something("Testing",$id)
              > >
              > > > and the sub get the second argument?
              >
              > but i will have to do
              >
              > sub something {
              > ($variable1,$variable2) = @_;
              > }
              > ??
              >
              >
              >
              >
              > >The arguments in the sub call are put in the
              > >pre-defined array @_. Take the 2nd one off
              > >just as you did the first.
              > >
              > >That's for simple scalar arguments.
              > >
              > >
              > >
              > >
              > >
              > >Your use of Yahoo! Groups is subject to
              > http://docs.yahoo.com/info/terms/
              >
              > ---
              >
              > [ r a f a e l f a r i a] _____________________
              > _________________rafaelrfc@...
              > WebMaster Universo Online - http://www.uol.com.br
              > Phone # +55 11 3038-8665
              >
              >


              __________________________________________________
              Do You Yahoo!?
              Get email at your own domain with Yahoo! Mail.
              http://personal.mail.yahoo.com/
            • Damien Carbery
              I recommend doing checking for the existance of the incoming parameters. Here are two ideas: sub something( $$ ) # $$ is like a prototype - 2 scalars
              Message 6 of 27 , Mar 21, 2001
                I recommend doing checking for the existance of the incoming
                parameters. Here are two ideas:

                sub something( $$ ) # $$ is like a prototype - 2 scalars expected.
                {
                # One way.
                my ( $variable1, $variable2 ) = @_;
                # You can quit the function if it is more appropriate.
                $variable1 = 'default value 1' if ( ! defined( $variable1 ) );
                $variable2 = 'default value 2' if ( ! defined( $variable2 ) );

                # Method two.
                my ( $variable1, $variable2 );
                if ( $#_ > -1 )
                {
                $variable1 = shift;
                }
                else
                {
                $variable1 = 'default value 1';
                }
                # etc.
                }

                The prototyping thing appears to be new for perl 5.6 (maybe even
                earlier). It doesn't appear to cause any complication errors, apart
                from a warning if you use this syntax and call the function before it
                is defined. If this is the case you have to put:
                sub something( $$ ); # A declaration.
                before the function is called.

                I don't believe the '&' before the function call is needed - I think
                that's something that was required up until some 5.x version of perl.

                --- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                >
                > > > how can i change my sub to work like that
                > > > &something("Testing",$id)
                > >
                > > > and the sub get the second argument?
                >
                > but i will have to do
                >
                > sub something {
                > ($variable1,$variable2) = @_;
                > }
                > ??
                >
                >
                >
                >
                > >The arguments in the sub call are put in the
                > >pre-defined array @_. Take the 2nd one off
                > >just as you did the first.
                > >
                > >That's for simple scalar arguments.
                > >
                > >
                > >
                > >
                > >
                > >Your use of Yahoo! Groups is subject to
                http://docs.yahoo.com/info/terms/
                >
                > ---
                >
                > [ r a f a e l f a r i a] _____________________
                > _________________rafaelrfc@u...
                > WebMaster Universo Online - http://www.uol.com.br
                > Phone # +55 11 3038-8665
              • Rafael Faria
                Hello guys, how can i make a session open with password? because if i got the address admin.cgi will ask for the password but if i try admin.cgi?action=show i
                Message 7 of 27 , Mar 21, 2001
                  Hello guys,

                  how can i make a session open with password?
                  because if i got the address

                  admin.cgi

                  will ask for the password

                  but if i try

                  admin.cgi?action=show
                  i will show the window befor the password...


                  what i want is.... i can't open admin.cgi?action=show or action=anything
                  without put the password...


                  some clue?

                  -rf
                • Damien Carbery
                  If you ve got Apache you can use .htaccess/htpasswd/htgroup files. I use a htpasswd file that resides outside the web site directory tree. I modified the
                  Message 8 of 27 , Mar 21, 2001
                    If you've got Apache you can use .htaccess/htpasswd/htgroup files.
                    I use a htpasswd file that resides outside the web site directory
                    tree.
                    I modified the httpd.conf file to restrict access to a certain
                    directory to the specified users.
                    It even worked on a subdirectory of the cgi-bin directory.
                    I've never tried it with individual files.

                    --- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                    > Hello guys,
                    >
                    > how can i make a session open with password?
                    > because if i got the address
                    >
                    > admin.cgi
                    >
                    > will ask for the password
                    >
                    > but if i try
                    >
                    > admin.cgi?action=show
                    > i will show the window befor the password...
                    >
                    >
                    > what i want is.... i can't open admin.cgi?action=show or
                    action=anything
                    > without put the password...
                    >
                    >
                    > some clue?
                    >
                    > -rf
                  • Rafael Faria
                    I know how to use it... but i was thinking in something with .cgi..... -rf ... [ r a f a e l f a r i a] _____________________
                    Message 9 of 27 , Mar 21, 2001
                      I know how to use it... but i was thinking in something with .cgi.....

                      -rf

                      >If you've got Apache you can use .htaccess/htpasswd/htgroup files.
                      >I use a htpasswd file that resides outside the web site directory
                      >tree.
                      >I modified the httpd.conf file to restrict access to a certain
                      >directory to the specified users.
                      >It even worked on a subdirectory of the cgi-bin directory.
                      >I've never tried it with individual files.
                      >
                      >--- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                      > > Hello guys,
                      > >
                      > > how can i make a session open with password?
                      > > because if i got the address
                      > >
                      > > admin.cgi
                      > >
                      > > will ask for the password
                      > >
                      > > but if i try
                      > >
                      > > admin.cgi?action=show
                      > > i will show the window befor the password...
                      > >
                      > >
                      > > what i want is.... i can't open admin.cgi?action=show or
                      >action=anything
                      > > without put the password...
                      > >
                      > >
                      > > some clue?
                      > >
                      > > -rf
                      >
                      >
                      >
                      >
                      >
                      >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

                      ---

                      [ r a f a e l f a r i a] _____________________
                      _________________rafaelrfc@...
                      WebMaster Universo Online - http://www.uol.com.br
                      Phone # +55 11 3038-8665
                    • Damien Carbery
                      Why reinvent the wheel? Apache s method is tried, tested and works. You d be doing well to even match its functionality. ... .cgi..... ...
                      Message 10 of 27 , Mar 21, 2001
                        Why reinvent the wheel?
                        Apache's method is tried, tested and works. You'd be doing well to
                        even match its functionality.

                        --- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                        > I know how to use it... but i was thinking in something with
                        .cgi.....
                        >
                        > -rf
                        >
                        > >If you've got Apache you can use .htaccess/htpasswd/htgroup files.
                        > >I use a htpasswd file that resides outside the web site directory
                        > >tree.
                        > >I modified the httpd.conf file to restrict access to a certain
                        > >directory to the specified users.
                        > >It even worked on a subdirectory of the cgi-bin directory.
                        > >I've never tried it with individual files.
                        > >
                        > >--- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                        > > > Hello guys,
                        > > >
                        > > > how can i make a session open with password?
                        > > > because if i got the address
                        > > >
                        > > > admin.cgi
                        > > >
                        > > > will ask for the password
                        > > >
                        > > > but if i try
                        > > >
                        > > > admin.cgi?action=show
                        > > > i will show the window befor the password...
                        > > >
                        > > >
                        > > > what i want is.... i can't open admin.cgi?action=show or
                        > >action=anything
                        > > > without put the password...
                        > > >
                        > > >
                        > > > some clue?
                        > > >
                        > > > -rf
                        > >
                        > >
                        > >
                        > >
                        > >
                        > >Your use of Yahoo! Groups is subject to
                        http://docs.yahoo.com/info/terms/
                        >
                        > ---
                        >
                        > [ r a f a e l f a r i a] _____________________
                        > _________________rafaelrfc@u...
                        > WebMaster Universo Online - http://www.uol.com.br
                        > Phone # +55 11 3038-8665
                      • Rafael Faria
                        Hi again, i have a form with undefined number of checkbox.... how can i pass to cgi how many checkbox are checked and what checkbox are checked like
                        Message 11 of 27 , Mar 21, 2001
                          Hi again,

                          i have a form with undefined number of checkbox....
                          how can i pass to cgi how many checkbox are checked and what checkbox are
                          checked

                          like

                          <TABLE width=100% BORDER=0 cellspacing=1 cellpadding=3 align=center>
                          <FORM ACTION=http://www.domain.com.br/cgi-local/ranking/admin.cgi
                          METHOD=POST NAME=scores>
                          <tr bgcolor=#E8F2F4><td width=10><input type=checkbox onclick=verTodos()
                          value=0></td><td width=70%><font face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=1></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=2></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=3></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=4></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=5></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr><tr bgcolor=#E8F2F4><td width=10><input
                          type=checkbox onclick=verTodos() value=6></td><td width=70%><font
                          face=verdana size=2>Teste
                          </font></td><td width=30% align=center><font size=2
                          face=verdana>1501</font></td></tr> <tr bgcolor="#FFFFFF">
                          <td><input name=br value=on type=checkbox onclick="checkaTodos()"></td>
                          <td colspan=2><a
                          href="javascript:document.scores.br.checked=!document.scores.br.checked;checkaTodos();"
                          onmouseover="window.status='Check All;return true;"><font face=verdana
                          size=1><b>Check All</b></font></a></td>
                          </form>
                          </tr>
                          </TABLE>

                          how can i get this values with cgi?

                          i don't know if it's clear.... but if i wanna print
                          like myprog.cgi?msg=Testing Script

                          i can put

                          print $FORM{'msg'};

                          how can i put all the number of i checked in an array?


                          someone understand me?
                        • Sean Quinlan
                          ... =snip ... I probably don t, but I ll try to help if I can. I know from experience that checkboxes in cgi are a real pain, and none of my old html/cgi books
                          Message 12 of 27 , Mar 22, 2001
                            At 12:40 AM 3/22/01 -0300, you wrote:
                            >Hi again,
                            >
                            >i have a form with undefined number of checkbox....
                            >how can i pass to cgi how many checkbox are checked and what checkbox are
                            >checked
                            >
                            >like
                            >
                            =snip
                            >
                            >how can i get this values with cgi?
                            >
                            >i don't know if it's clear.... but if i wanna print
                            >like myprog.cgi?msg=Testing Script
                            >
                            >i can put
                            >
                            >print $FORM{'msg'};
                            >
                            >how can i put all the number of i checked in an array?
                            >
                            >
                            >someone understand me?
                            >

                            I probably don't, but I'll try to help if I can. I know from experience
                            that checkboxes in cgi are a real pain, and none of my old html/cgi books
                            ever seemed to make it much clearer, indeed they frequently conflicted.
                            Maybe there is a newer (< 3 years) resource out there someone could recomend?

                            Also, what are you using to parse the cgi input? CGI.pm? Something home
                            rolled? Since form data is passed as key value pairs (at least in all
                            implimentations I'm familiar with), some post proccessing will need to be
                            done to get the data from the checkboxes into an array. And _ALWAYS_ use
                            taint;!

                            First off, in this specific case, it looks like you are using javascript to
                            do something each time a checkbox is clicked, and I don't see a submit
                            button for your form. This makes it even harder to guess what's going on.
                            If your 'submit' like event is clicking the checkbox, I would recomend
                            using radiobotton's instead.

                            If your just doing some preparsing or something and the submit is missing,
                            the only other thing I noticed is that most of your checkbuttons have a
                            value, but no name, which could be your entire problem.

                            Anywho, the easiest thing I have found is to give each checkbox a different
                            name as well as the appropriate value. This has worked well enough for me
                            over the years. I have tried naming all checkboxes in the same form section
                            the same with different values (as in radiobuttons), but this has proven
                            horribly problematic to parse. Instead I give each checkbox in a section
                            the same prefix, and then usually the value, so an example from your
                            submision might be:
                            <input type=checkbox onclick=verTodos() name="ranking-4" value="4">

                            HTH,

                            --------------------------------------------------------------------------
                            Sean P. Quinlan
                            http://people.ne.mediaone.net/squinlan/index.html
                            mailto:squinlan@...

                            "You can discover more about a person in an hour of play than in a year of
                            conversation" - Plato
                          • Rafael Faria
                            I tried ================================================== #!/usr/bin/perl use CGI; $query = new CGI; require functions.lib ; &ReadParse; print Content-type:
                            Message 13 of 27 , Mar 22, 2001
                              I tried

                              ==================================================
                              #!/usr/bin/perl
                              use CGI;
                              $query = new CGI;

                              require "functions.lib";
                              &ReadParse;

                              print "Content-type: text/html\n\n";
                              &now($query);
                              &show($query);

                              sub show {
                              #my($query) = @_;
                              print "<H2>Here are the current settings in this form</H2>";
                              @test = $query->param(checkscores);
                              foreach (@test) {
                              print "$_<BR>";
                              }
                              }
                              sub now {
                              my($query) = @_;
                              print <<END;
                              <TABLE width=300 BORDER=0 cellspacing=0 cellpadding=0
                              align=center><tr><td b
                              gcolor=#000000>
                              <TABLE width=100% BORDER=0 cellspacing=1 cellpadding=3 align=center>
                              <FORM ACTION=http://www.vacamarela.com.br/cgi-local/ranking/teste.pl
                              METHOD=P
                              OST NAME=scores>
                              <input type=hidden name="action" value="teste">
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=0><
                              /td><td width=70%><font face=verdana size=2>Teste
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=1><
                              /td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=2><
                              /td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=3><
                              /td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores
                              type=checkbox value=4>
                              </td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=5><
                              /td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#E8F2F4><td width=10><input name=checkscores type=checkbox
                              value=6><
                              /td><td width=70%><font face=verdana size=2>Test
                              </font></td><td width=30% align=center><font size=2
                              face=verdana>1501</font></td
                              ></tr>
                              <tr bgcolor=#FFFFFF><td colspan=3 align=center><input type=submit
                              value=Submit><
                              /td></tr>
                              </form>
                              </TABLE>
                              </td></tr></table>
                              END
                              }
                              ============================================


                              and it works getting what i check........BUTTTTTTTTTTTTTTT i wanna get all
                              that AREN'T CHECKED...... some clue? :P



                              >At 12:40 AM 3/22/01 -0300, you wrote:
                              > >Hi again,
                              > >
                              > >i have a form with undefined number of checkbox....
                              > >how can i pass to cgi how many checkbox are checked and what checkbox are
                              > >checked
                              > >
                              > >like
                              > >
                              >=snip
                              > >
                              > >how can i get this values with cgi?
                              > >
                              > >i don't know if it's clear.... but if i wanna print
                              > >like myprog.cgi?msg=Testing Script
                              > >
                              > >i can put
                              > >
                              > >print $FORM{'msg'};
                              > >
                              > >how can i put all the number of i checked in an array?
                              > >
                              > >
                              > >someone understand me?
                              > >
                              >
                              >I probably don't, but I'll try to help if I can. I know from experience
                              >that checkboxes in cgi are a real pain, and none of my old html/cgi books
                              >ever seemed to make it much clearer, indeed they frequently conflicted.
                              >Maybe there is a newer (< 3 years) resource out there someone could recomend?
                              >
                              >Also, what are you using to parse the cgi input? CGI.pm? Something home
                              >rolled? Since form data is passed as key value pairs (at least in all
                              >implimentations I'm familiar with), some post proccessing will need to be
                              >done to get the data from the checkboxes into an array. And _ALWAYS_ use
                              >taint;!
                              >
                              >First off, in this specific case, it looks like you are using javascript to
                              >do something each time a checkbox is clicked, and I don't see a submit
                              >button for your form. This makes it even harder to guess what's going on.
                              >If your 'submit' like event is clicking the checkbox, I would recomend
                              >using radiobotton's instead.
                              >
                              >If your just doing some preparsing or something and the submit is missing,
                              >the only other thing I noticed is that most of your checkbuttons have a
                              >value, but no name, which could be your entire problem.
                              >
                              >Anywho, the easiest thing I have found is to give each checkbox a different
                              >name as well as the appropriate value. This has worked well enough for me
                              >over the years. I have tried naming all checkboxes in the same form section
                              >the same with different values (as in radiobuttons), but this has proven
                              >horribly problematic to parse. Instead I give each checkbox in a section
                              >the same prefix, and then usually the value, so an example from your
                              >submision might be:
                              ><input type=checkbox onclick=verTodos() name="ranking-4" value="4">
                              >
                              >HTH,
                              >
                              >--------------------------------------------------------------------------
                              >Sean P. Quinlan
                              >http://people.ne.mediaone.net/squinlan/index.html
                              >mailto:squinlan@...
                              >
                              >"You can discover more about a person in an hour of play than in a year of
                              >conversation" - Plato
                              >
                              >
                              >
                              >
                              >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

                              ---

                              [ r a f a e l f a r i a] _____________________
                              _________________rafaelrfc@...
                              WebMaster Universo Online - http://www.uol.com.br
                              Phone # +55 11 3038-8665
                            • Sean Quinlan
                              ... You should be doing: #!/usr/bin/perl -wT use strict; I know this sounds a little preachy, and it s a pain to adjust to. But -T can save your but - it s not
                              Message 14 of 27 , Mar 22, 2001
                                At 03:23 PM 3/22/01 -0300, you wrote:
                                >I tried
                                >
                                >==================================================
                                >#!/usr/bin/perl

                                You should be doing:
                                #!/usr/bin/perl -wT
                                use strict;

                                I know this sounds a little preachy, and it's a pain to adjust to. But -T
                                can save your but - it's not the end all and be all of security by any
                                means, but it helps. -w and use strict will make you work a little harder
                                when writting, but before long you will find you make far fewer mistakes,
                                both by learning better habbits, and because -w will help quickly solve
                                lots of simple problems. I promise you it is worth it in the long run.

                                >use CGI;
                                >$query = new CGI;
                                >
                                >require "functions.lib";
                                >&ReadParse;

                                I'm not familiar with functions.lib and ReadParse. Are they yours or have I
                                just missed them?

                                >
                                >print "Content-type: text/html\n\n";
                                > &now($query);
                                > &show($query);
                                >
                                >sub show {
                                > #my($query) = @_;
                                > print "<H2>Here are the current settings in this form</H2>";
                                > @test = $query->param(checkscores);
                                > foreach (@test) {
                                > print "$_<BR>";
                                > }
                                >}

                                Does @test = $query->param(checkscores); work?!? It's been a long time
                                since I read docs for CGI. Does it capture all the values returned for the
                                named set of checkboxes? If that functions now, VERY cool!

                                =snip
                                >
                                >and it works getting what i check........BUTTTTTTTTTTTTTTT i wanna get all
                                >that AREN'T CHECKED...... some clue? :P
                                >

                                Hmm, have them all checked by default and have the the user uncheck as
                                appropriate? The only other suggestion I would have would be to keep a hash
                                of all possible values to check against. So you would want to initialize
                                the hash with all your value options as keys, and the values just being
                                true. Since your values are numeric in this example, that's fairly easy.

                                my %checkscores;
                                foreach my $n (0..6) { $checkscores{$n} = "true" } # or = 1.

                                The same hash could be used in a loop to write the checkbox portion of the
                                html if you wanted to maintain the html and hash in concordance.

                                Then you would test in your response like:

                                @test = $query->param(checkscores);
                                foreach my $key (keys %checkscores) {
                                next if (grep {/$key/} @test);
                                print "$key<BR>";
                                # or print "$key<BR>" unless (grep {/$key/} @test);
                                } # foreach

                                Or a more compact method that might work would be:

                                @test = $query->param(checkscores);
                                foreach my $n (0..6) { print "$n<BR>" unless (grep {/$n/} @test) }

                                Or maybe something assigning to a hash (or deleteing from?) directly with
                                param's return list:

                                my %checkscores;
                                foreach my $key ($query->param(checkscores)) {
                                $checkscores{$key} = "true";
                                } # foreach

                                Hey, this is fun, much better than working! :D Have I confused you yet?
                                Anywho, The point here is just that, as far as I know, cgi forms only
                                return the values actually checked, so there is no way to know what was
                                unchecked without adding something. I suppose the most robust way would be
                                to actually have a <input type=hidden... in the html that passes the cgi
                                script the list of all possible checkbox values, so all the data is
                                selfcontained in the form.

                                HTH!,

                                --------------------------------------------------------------------------
                                Sean P. Quinlan
                                http://people.ne.mediaone.net/squinlan/index.html
                                mailto:squinlan@...

                                "You can discover more about a person in an hour of play than in a year of
                                conversation" - Plato
                              • Rafael Faria
                                Hi... i m again :P i have an array @test = ( 0 , 1 , 2 , 3 , 4 , 5 ); how can i del the number 1 position [1] and then get the array ( 0 , 2 , 3 , 4 , 5 ) ??
                                Message 15 of 27 , Mar 22, 2001
                                  Hi...

                                  i'm again :P

                                  i have an array

                                  @test = ("0","1","2","3","4","5");


                                  how can i del the number "1" position [1] and then get the array

                                  ("0","2","3","4","5")

                                  ??
                                • Damien Carbery
                                  From perlfunc: splice ARRAY,OFFSET,LENGTH For you: splice( @test, 1, 1 );
                                  Message 16 of 27 , Mar 22, 2001
                                    From perlfunc:
                                    splice ARRAY,OFFSET,LENGTH

                                    For you:
                                    splice( @test, 1, 1 );

                                    --- In perl-beginner@y..., Rafael Faria <rafaelrfc@b...> wrote:
                                    > Hi...
                                    >
                                    > i'm again :P
                                    >
                                    > i have an array
                                    >
                                    > @test = ("0","1","2","3","4","5");
                                    >
                                    >
                                    > how can i del the number "1" position [1] and then get the array
                                    >
                                    > ("0","2","3","4","5")
                                    >
                                    > ??
                                  • Rafael Faria
                                    ... it s my personal library :P ... YEAP.... it get all the checkedbox and put into a array... i read it in somewere.... but i wanna get just what ISN T
                                    Message 17 of 27 , Mar 22, 2001
                                      > >use CGI;
                                      > >$query = new CGI;
                                      > >
                                      > >require "functions.lib";
                                      > >&ReadParse;
                                      >
                                      >I'm not familiar with functions.lib and ReadParse. Are they yours or have I
                                      >just missed them?

                                      it's my personal library :P


                                      > >
                                      > >print "Content-type: text/html\n\n";
                                      > > &now($query);
                                      > > &show($query);
                                      > >
                                      > >sub show {
                                      > > #my($query) = @_;
                                      > > print "<H2>Here are the current settings in this form</H2>";
                                      > > @test = $query->param(checkscores);
                                      > > foreach (@test) {
                                      > > print "$_<BR>";
                                      > > }
                                      > >}
                                      >
                                      >Does @test = $query->param(checkscores); work?!? It's been a long time
                                      >since I read docs for CGI. Does it capture all the values returned for the
                                      >named set of checkboxes? If that functions now, VERY cool!

                                      YEAP.... it get all the checkedbox and put into a array... i read it in
                                      somewere.... but i wanna get just what ISN'T checked but i can't figure out
                                      HOW... :P


                                      >@test = $query->param(checkscores);
                                      >foreach my $n (0..6) { print "$n<BR>" unless (grep {/$n/} @test) }

                                      IT WORKS to get NONCHECKED :P

                                      i will see if i can with it :P i will also try this code under!

                                      thanks Sean! :P

                                      -rf


                                      >Or maybe something assigning to a hash (or deleteing from?) directly with
                                      >param's return list:
                                      >
                                      >my %checkscores;
                                      >foreach my $key ($query->param(checkscores)) {
                                      > $checkscores{$key} = "true";
                                      >} # foreach
                                      >
                                      >Hey, this is fun, much better than working! :D Have I confused you yet?
                                      >Anywho, The point here is just that, as far as I know, cgi forms only
                                      >return the values actually checked, so there is no way to know what was
                                      >unchecked without adding something. I suppose the most robust way would be
                                      >to actually have a <input type=hidden... in the html that passes the cgi
                                      >script the list of all possible checkbox values, so all the data is
                                      >selfcontained in the form.
                                      >
                                      >HTH!,
                                      >
                                      >--------------------------------------------------------------------------
                                      >Sean P. Quinlan
                                      >http://people.ne.mediaone.net/squinlan/index.html
                                      >mailto:squinlan@...
                                      >
                                      >"You can discover more about a person in an hour of play than in a year of
                                      >conversation" - Plato
                                      >
                                      >
                                      >
                                      >
                                      >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

                                      ---

                                      [ r a f a e l f a r i a] _____________________
                                      _________________rafaelrfc@...
                                      WebMaster Universo Online - http://www.uol.com.br
                                      Phone # +55 11 3038-8665
                                    • Rafael Faria
                                      Everything was going ok... but when i added the code use CGI; $query = new CGI; it doens t work anymore... .some clue? -rf
                                      Message 18 of 27 , Mar 22, 2001
                                        Everything was going ok... but when i added the code

                                        use CGI;
                                        $query = new CGI;

                                        it doens't work anymore... .some clue?

                                        -rf
                                      • JHILMIL JAIN
                                        I am a bigenner.. but this is what I got... #!usr/local/bin/perl @test=( 0 , 1 , 2 , 3 , 4 , 5 ); print @test; $temp=shift(@test); $remove=shift(@test);
                                        Message 19 of 27 , Mar 22, 2001
                                          I am a bigenner..
                                          but this is what I got...

                                          #!usr/local/bin/perl

                                          @test=("0","1","2","3","4","5");

                                          print @test;

                                          $temp=shift(@test);
                                          $remove=shift(@test);
                                          unshift(@test,$temp);

                                          print "\nafter manipulations :@test";


                                          -Jhilmil.



                                          Quoting Rafael Faria <rafaelrfc@...>:

                                          > Hi...
                                          >
                                          > i'm again :P
                                          >
                                          > i have an array
                                          >
                                          > @test = ("0","1","2","3","4","5");
                                          >
                                          >
                                          > how can i del the number "1" position [1] and then get the array
                                          >
                                          > ("0","2","3","4","5")
                                          >
                                          > ??
                                          >
                                          >
                                          >
                                          >
                                          > ------------------------ Yahoo! Groups Sponsor
                                          >
                                          >
                                          >
                                          > Your use of Yahoo! Groups is subject to
                                          > http://docs.yahoo.com/info/terms/
                                          >
                                          >





                                          --------------------------------------------------------------------------------
                                          Jhilmil Jain Office: Shop Building 105
                                          Dept. of Computer Science Office Phone #: (334) 844-6323
                                          Auburn University E-Mail: jhilmilj@...
                                          --------------------------------------------------------------------------------
                                        • Gail K
                                          Rafael; Start reading here: http://www.netcat.co.uk/rob/perl/win32perltut.html#72-JiggerypokerywithArray s Jiggerypokery with Arrays What a great tutorial!
                                          Message 20 of 27 , Mar 22, 2001
                                            Rafael;

                                            Start reading here:

                                            http://www.netcat.co.uk/rob/perl/win32perltut.html#72-JiggerypokerywithArray
                                            s

                                            Jiggerypokery with Arrays

                                            What a great tutorial!

                                            Best of luck!




                                            ----- Original Message -----
                                            From: "Rafael Faria" <rafaelrfc@...>
                                            To: <perl-beginner@yahoogroups.com>
                                            Sent: Thursday, March 22, 2001 1:48 PM
                                            Subject: [PBML] Array


                                            > Hi...
                                            >
                                            > i'm again :P
                                            >
                                            > i have an array
                                            >
                                            > @test = ("0","1","2","3","4","5");
                                            >
                                            >
                                            > how can i del the number "1" position [1] and then get the array
                                            >
                                            > ("0","2","3","4","5")
                                            >
                                            > ??
                                            >
                                            >
                                            >
                                            >
                                            >
                                            >
                                            >
                                            > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                                            >
                                            >
                                          • Sean Quinlan
                                            ... Use splice (camel 3, pg 793). In brief, splice allows you to add (or replace) values into an array. splice(@a,$b,$c,@d) where a is the array to operate on,
                                            Message 21 of 27 , Mar 22, 2001
                                              At 04:48 PM 3/22/01 -0300, you wrote:
                                              >Hi...
                                              >
                                              >i'm again :P
                                              >
                                              >i have an array
                                              >
                                              >@test = ("0","1","2","3","4","5");
                                              >
                                              >
                                              >how can i del the number "1" position [1] and then get the array
                                              >
                                              >("0","2","3","4","5")
                                              >
                                              >??
                                              >

                                              Use splice (camel 3, pg 793). In brief, splice allows you to add (or
                                              replace) values into an array. splice(@a,$b,$c,@d) where a is the array to
                                              operate on, $b is the index to begin at (offset), $c is the number of
                                              indexes to operate on (a 0 inserts without deleteing any indexes), and @d
                                              is the list (_not_ neccisarily an array) to splice into @a. So
                                              splice(@test,2,0,("a","b")); would turn your original array into
                                              ("0","1","2","a","b","3","4","5"), wheras splice(@test,0,2,("a","b"));
                                              would make it ("a","b","2","3","4","5"). If no value is given for the list,
                                              then splice deletes $c # of indexes starting with
                                              index $b.

                                              So,
                                              If you know the index(position) you want to remove:
                                              splice(@test,1,1);

                                              If you only know the value:
                                              for (my $i=0;$i<@test;$i++) {
                                              if ($test[$i] == $val_to_remove) { # if both numeric, else use eq
                                              splice(@test,$i,1);
                                              last; # unless there may be more than one instance to remove
                                              } # if
                                              } # for

                                              HTH,

                                              --------------------------------------------------------------------------
                                              Sean P. Quinlan
                                              http://people.ne.mediaone.net/squinlan/index.html
                                              mailto:squinlan@...

                                              "You can discover more about a person in an hour of play than in a year of
                                              conversation" - Plato
                                            • Rafael Faria
                                              Thanks Gail... really great! :P Rafael ... [ r a f a e l f a r i a] _____________________ _________________rafaelrfc@uol.com.br WebMaster Universo Online -
                                              Message 22 of 27 , Mar 22, 2001
                                                Thanks Gail... really great! :P

                                                Rafael

                                                >Rafael;
                                                >
                                                >Start reading here:
                                                >
                                                >http://www.netcat.co.uk/rob/perl/win32perltut.html#72-JiggerypokerywithArray
                                                >s
                                                >
                                                >Jiggerypokery with Arrays
                                                >
                                                >What a great tutorial!
                                                >
                                                >Best of luck!
                                                >
                                                >
                                                >
                                                >
                                                >----- Original Message -----
                                                >From: "Rafael Faria" <rafaelrfc@...>
                                                >To: <perl-beginner@yahoogroups.com>
                                                >Sent: Thursday, March 22, 2001 1:48 PM
                                                >Subject: [PBML] Array
                                                >
                                                >
                                                > > Hi...
                                                > >
                                                > > i'm again :P
                                                > >
                                                > > i have an array
                                                > >
                                                > > @test = ("0","1","2","3","4","5");
                                                > >
                                                > >
                                                > > how can i del the number "1" position [1] and then get the array
                                                > >
                                                > > ("0","2","3","4","5")
                                                > >
                                                > > ??
                                                > >
                                                > >
                                                > >
                                                > >
                                                > >
                                                > >
                                                > >
                                                > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                                                > >
                                                > >
                                                >
                                                >
                                                >
                                                >
                                                >
                                                >
                                                >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

                                                ---

                                                [ r a f a e l f a r i a] _____________________
                                                _________________rafaelrfc@...
                                                WebMaster Universo Online - http://www.uol.com.br
                                                Phone # +55 11 3038-8665
                                              • Firman Sugiharto
                                                Hi everybody, I m new in this group and I just learned Perl. Can anybody tell me how to know the index of an array element? For example, I have an array @month
                                                Message 23 of 27 , Jun 12, 2001
                                                  Hi everybody, I'm new in this group and I just learned Perl. Can
                                                  anybody tell me how to know the index of an array element?
                                                  For example, I have an array

                                                  @month = (1=>"January", "February", "March", "April");

                                                  If I want to know what is the second month, I could easily write

                                                  print @array[2];

                                                  but what if I want to know the index of "February"?

                                                  Thanks in advance.
                                                • bob_showalter@taylorwhite.com
                                                  ... Watch out: this list has 5 elements. The first element is the number 1. In perl, the = operator is equivalent to a comma, with the exception that
                                                  Message 24 of 27 , Jun 12, 2001
                                                    --- In perl-beginner@y..., "Firman Sugiharto" <umgekehrt@y...> wrote:
                                                    > Hi everybody, I'm new in this group and I just learned Perl. Can
                                                    > anybody tell me how to know the index of an array element?
                                                    > For example, I have an array
                                                    >
                                                    > @month = (1=>"January", "February", "March", "April");

                                                    Watch out: this list has 5 elements. The first element is the
                                                    number 1. In perl, the => operator is equivalent to a comma, with
                                                    the exception that barewords to the left of => do not need to be
                                                    quoted. This notation is commonly used for hash initialization.

                                                    >
                                                    > If I want to know what is the second month, I could easily write
                                                    >
                                                    > print @array[2];
                                                    >
                                                    > but what if I want to know the index of "February"?

                                                    If you only need to find the index once, you just use a brute
                                                    force search:

                                                    undef $i;
                                                    for (0 .. $#month)
                                                    {
                                                    $i = $_, last if $month[$_] eq "February";
                                                    }

                                                    # now $i is index of February, or undef if February
                                                    # is not in the list

                                                    If you need to do this multiple times, you may want to make up
                                                    a hash:

                                                    @mon{@month} = 0 .. $#month; # creates hash %mon
                                                    print $mon{February}; # prints 2
                                                    print $mon{April}; # prints 4

                                                    -- Bob
                                                  • Firman Sugiharto
                                                    Thanks Bob, I appreciate it.
                                                    Message 25 of 27 , Jun 15, 2001
                                                      Thanks Bob, I appreciate it.

                                                      --- In perl-beginner@y..., bob_showalter@t... wrote:
                                                      > --- In perl-beginner@y..., "Firman Sugiharto" <umgekehrt@y...>
                                                      wrote:
                                                      > > Hi everybody, I'm new in this group and I just learned Perl. Can
                                                      > > anybody tell me how to know the index of an array element?
                                                      > > For example, I have an array
                                                      > >
                                                      > > @month = (1=>"January", "February", "March", "April");
                                                      >
                                                      > Watch out: this list has 5 elements. The first element is the
                                                      > number 1. In perl, the => operator is equivalent to a comma, with
                                                      > the exception that barewords to the left of => do not need to be
                                                      > quoted. This notation is commonly used for hash initialization.
                                                    • anil
                                                      Hi All, $textmatter= sdfjsd fjgj fig1 jfbj fig1 fg hjhg tab1 djhdj tab2 asdjfj tab1 ; @array=$textmatter=~/ (fig[0-9]+|tab[0-9]+) /g; print @array ;
                                                      Message 26 of 27 , Jan 11, 2008
                                                        Hi All,

                                                        $textmatter='sdfjsd fjgj "fig1" jfbj "fig1" fg hjhg "tab1"
                                                        djhdj "tab2" asdjfj "tab1"';
                                                        @array=$textmatter=~/"(fig[0-9]+|tab[0-9]+)"/g;
                                                        print "@array";

                                                        OUTPUT: fig1 fig1 tab1 tab2 tab1

                                                        REQUIRED OUTPUT: fig1 tab1 tab2

                                                        I need the first occurance of fig or tab details in the statment. How
                                                        can i do this. Please suggest.
                                                      • Jenda Krynicky
                                                        From: anil ... You can t do that in the regexp. (Well ... you can, if you are very very cheaky. Unless the strings are
                                                        Message 27 of 27 , Jan 11, 2008
                                                          From: "anil" <n.selvakumar@...>
                                                          > Hi All,
                                                          >
                                                          > $textmatter='sdfjsd fjgj "fig1" jfbj "fig1" fg hjhg "tab1"
                                                          > djhdj "tab2" asdjfj "tab1"';
                                                          > @array=$textmatter=~/"(fig[0-9]+|tab[0-9]+)"/g;
                                                          > print "@array";
                                                          >
                                                          > OUTPUT: fig1 fig1 tab1 tab2 tab1
                                                          >
                                                          > REQUIRED OUTPUT: fig1 tab1 tab2
                                                          >
                                                          > I need the first occurance of fig or tab details in the statment. How
                                                          > can i do this. Please suggest.

                                                          You can't do that in the regexp. (Well ... you can, if you are very
                                                          very cheaky. Unless the strings are really huge and contain lots of
                                                          repeats I'd rather not go there.)

                                                          You have to filter it later.

                                                          See

                                                          perldoc -q duplicate

                                                          HTH, Jenda
                                                          ===== Jenda@... === http://Jenda.Krynicky.cz =====
                                                          When it comes to wine, women and song, wizards are allowed
                                                          to get drunk and croon as much as they like.
                                                          -- Terry Pratchett in Sourcery
                                                        Your message has been successfully submitted and would be delivered to recipients shortly.