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

need help with sort::fields

Expand Messages
  • Anila Thomas
    Hi, I am trying to use the sort::fields to sort on multiple sortkeys. I notice that the multikey sort does not work for the sample data attached as
    Message 1 of 3 , Mar 4, 2004
    • 0 Attachment
      Hi,

      I am trying to use the sort::fields to sort on multiple sortkeys.
      I notice that the multikey sort does not work for the sample data attached as sortfld_eg.txt. ie when i try various combinations of alpha and number sort on the data for 2 or 3 levels of sorting , the desired output is not acheived.

      Am attaching the sort program.

      To try out sort combinations, pls change the values of $field1,$field2,$field3 in the program ..


      Pls help!!!

      regds
      Anila Thomas


      ----------

      123|asd|1.22|asdd
      32|ewq|2.32|asdd
      43|rewq|2.12|ewet
      51|erwt|34.2|ewet
      23|erww|4.21|ewet
      91|fdgs|3.43|ewet
      123|refs|3.22|fsdd
      123|refs|4.32|asdd


      [Non-text portions of this message have been removed]
    • Cristi Ocolisan
      Hello everyone! I have a problem I cannot solve alone. Please help me. I just started to work with MySQL and I m stuck. I wrote the following code to
      Message 2 of 3 , Mar 4, 2004
      • 0 Attachment
        Hello everyone!



        I have a problem I cannot solve alone. Please help me.



        I just started to work with MySQL and I'm stuck. I wrote the following code
        to interrogate a database called "ncp", but when I execute it only the first
        row from my table "persoane" is printed on screen.



        Can anyone tell me where I go wrong?



        Here is the code. For someone with experience it may look like very simple
        but again I just started to work with MySQL.





        #!/usr/bin/perl



        use DBI;

        use CGI;



        my $dsn = 'dbi:mysql:ncp';

        my $user = 'root';

        my $pass = '';



        #$nume = "Ocolisan";



        my $dbh = DBI->connect($dsn,$user,$pass) or die "Cannot connect!";



        my $sth = $dbh->prepare("select * from persoane");



        $sth->execute();



        while (@row = $sth->fetchrow_array()){

        print "$row[0] $row[1] $row[2] $row[3] $row[4] $row[5]<br>";

        }



        Thank you



        CO







        [Non-text portions of this message have been removed]
      • daymobrew@yahoo.com
        ... following code ... the first ... simple ... Looking at http://hantach.hypermart.net/perldoc/dbd-dbimodule.html I think you may need to change your DSN to
        Message 3 of 3 , Mar 4, 2004
        • 0 Attachment
          --- In perl-beginner@yahoogroups.com, "Cristi Ocolisan" <cristi@w...>
          wrote:
          > Hello everyone!
          >
          > I have a problem I cannot solve alone. Please help me.
          >
          > I just started to work with MySQL and I'm stuck. I wrote the
          following code
          > to interrogate a database called "ncp", but when I execute it only
          the first
          > row from my table "persoane" is printed on screen.
          >
          >
          >
          > Can anyone tell me where I go wrong?
          >
          >
          >
          > Here is the code. For someone with experience it may look like very
          simple
          > but again I just started to work with MySQL.
          >
          >
          > #!/usr/bin/perl
          >
          > use DBI;
          > use CGI;
          >
          > my $dsn = 'dbi:mysql:ncp';
          > my $user = 'root';
          > my $pass = '';
          >
          > #$nume = "Ocolisan";
          >
          > my $dbh = DBI->connect($dsn,$user,$pass) or die "Cannot connect!";
          >
          > my $sth = $dbh->prepare("select * from persoane");
          > $sth->execute();
          >
          > while (@row = $sth->fetchrow_array()){
          > print "$row[0] $row[1] $row[2] $row[3] $row[4] $row[5]<br>";
          > }
          >
          > Thank you
          >
          > CO

          Looking at
          http://hantach.hypermart.net/perldoc/dbd-dbimodule.html
          I think you may need to change your DSN to

          my $dsn = 'DBI:mysql:ncp'; # Caps for 'DBI'.

          Aside:
          1) Give the MySQL root user a password. It is very dangerous not to.
          2) Consider setting up a MySQL account which can only read the
          database. Then use this user in your script. This will ensure your CGI
          script cannot be used to change your database.
        Your message has been successfully submitted and would be delivered to recipients shortly.