Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    28

    Unanswered: 2 quick questions

    The first one is:

    When I use a SELECT statement in MySQL to return rows in a table, I get a grandtotal count at the bottom when the console returns the specified rows. I am selecting rows INTO OUTFILE and I do not want the grandtotal part included in the txt file. Is there anyway to get rid of it?

    The second one has to do with PERL, so hopefully one of you PERL gurus will know the answer:

    I am concatenating text in the code as follows:

    Code:
    @user_name[$i] = @user_name[$i].1;
    I simply want to attach a 1 to the end of the user_name, but when I do it leaves a space between the user_name and the 1, so it looks like this:

    bperry 1 instead of bperry1

    Is there a way to get rid of that space?

    Brian

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Suppressing the "decoration" rows depends on what is producing them. The simple answer in this case is just to have perl ignore them.

    The space is because 1 is a number. Now "1" is a string. That should work better!

    -PatP

  3. #3
    Join Date
    May 2004
    Posts
    28
    Thanks for the help, I'll get PERL to ignore those lines. However, changing 1 to "1" didn't fix the problem. Any other ideas? Here is a bit more of the code I am using:


    Code:
    ####this assigns a 1 to the end of particular users that meet the requirement with in the loop that this line is contained####
    @user_name[$i] = @user_name[$i]."1";
    
    ####this line sorts the array####
    @user_name2 = sort{$a cmp $b}@user_name;
    
    ####this part outputs to HTML####
    for ($i=0;$i<$count;$i++)
    {
    	print "@user_name2[$i]";
    	print "<br>";
    }
    Now the source code for HTML output looks like this where users have a 1 at the end of their user_name:

    Code:
    <br>SLucero
    <br>SManzo
    <br>SMartinez
    <br>SMartinez
    1<br>SMaxwell
    <br>SMiers
    <br>SMooney
    <br>SParzyk

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Just for the jolly factor, between the first a second lines that you posted try using:
    Code:
    chop(@user_name[$i]);
    -PatP

  5. #5
    Join Date
    May 2004
    Posts
    28
    Great! That worked, thanks alot,

    Brian

  6. #6
    Join Date
    May 2004
    Posts
    28
    I also have another question. How do you return the first character of an array?

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    There are more ways to get the first character than I can easily count, and each has its own advantages and disadvantages. The "brute force" and "one size fits all" solution is:
    Code:
    $firstchar = SubString(@array[0], 1, 1);
    Depending on just what you envision doing, there are probably both more elegant and more efficient ways of doing that.

    -PatP

  8. #8
    Join Date
    May 2004
    Posts
    28
    thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •