Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: everyauction script error bidding errors

by mkmcconn (Chaplain)
on Jun 21, 2005 at 23:21 UTC ( #468851=note: print w/replies, xml ) Need Help??


in reply to Re^2: everyauction script error bidding errors
in thread everyauction script error bidding errors

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://468851]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2023-02-04 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?