Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: everyauction script error bidding errors

by mkmcconn (Chaplain)
on Jun 21, 2005 at 21:57 UTC ( [id://468828]=note: print w/replies, xml ) Need Help??


in reply to everyauction script error bidding errors

simonwilliams, you wrote,
if($#bids){ for (my $i = $#bids; $i > 1; $i = 1) { ... } }
Where I'm pretty sure that what you meant was,
if (@bids > 1){ for (my $i = 0; $i <= $#bids; $i++) { ... } }
But, many of us would prefer to write this as:
if (@bids > 1){ for my $bid (@bids){ my ($alias, $email, $bid, $time, $add1, $add2, $add3) = readbid($b +id); } }
You also wrote,
$time = sort ({ int $a <=> int $b } $time);

This will not do anything. $time is not a LIST. See perldoc -f sort;

By the way, you'll get better answers if you work harder on distilling your question to one essential issue. Hope all this helps, and welcome to the Monastery.
mkmcconn

Replies are listed 'Best First'.
Re^2: everyauction script error bidding errors
by simonwilliams (Initiate) on Jun 21, 2005 at 22:54 UTC
    If i replace the code with this;
    my $lowest_new_bid; if ($#bids) { for (my $i=1; $i<scalar(@bids); $i++) { my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $sold +qty) = &read_bid($bids[$i]); if (($form{'ALIAS'} ne $lastbid[0]) && ($form{'ALIAS'} eq $alias)) + { if (($form{'ALIAS'} ne $firstbid[0]) && ($form{'ALIAS'} eq $alias) +) {
    it works but it now prints all the bids the user has placed on the item and i need it to only display the highest last placed bid but under the current high bid of the highest bidder.

      simonwilliams,

      1.    if ($#bids){...}
        does what you mean, but it doesn't really say what you mean. For that, you should say
           if (@bids > 1){ ... };
        i.e., if @bids contains more bids than one, then ...
      2.   for (my $i=1; $i<scalar(@bids); $i++) { ... }
        could be written ...
          for (my $i=1; $i < @bids; $i++) { ... }
        ... without any change in meaning. @bids is being evaluated in a scalar context. No need to say scalar() explicitly.
      3. Let me oversimplify your problem, and you can build on that. You want to choose the highest bid, excluding your own from consideration (always the first bid), and print only the highest bid.
        my $highest; if (@bids > 1){ for (my $i = 1; $i < @bids; $i++) { my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = read_bid($bids[$i]); $highest = $bid > $highest ? $bid : $highest; } print "Highest bid: $highest\n"; }

      mkmcconn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://468828]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found