Re: obj 8-2

Discussion in 'Perl Misc' started by George Mpouras, Feb 21, 2014.

  1. > a beginner it's not always easy to translate the information into actual
    > code. That being said, this is what I came up with.
    >


    here is some actual code


    my @array = qw(42 41 42 31 54 420 56 57 46 58 59 60 34 61);
    my $max = shift @array;
    $_ > $max and $max = $_ foreach @array;
    print $max;
    George Mpouras, Feb 21, 2014
    #1
    1. Advertising

  2. George Mpouras

    John Bokma Guest

    Marek Novotny <> writes:

    > On Fri, 21 Feb 2014 22:45:16 +0200, George Mpouras wrote:
    >
    >>> a beginner it's not always easy to translate the information into
    >>> actual code. That being said, this is what I came up with.
    >>>
    >>>

    >> here is some actual code
    >>
    >>
    >> my @array = qw(42 41 42 31 54 420 56 57 46 58 59 60 34 61);

    ^^^

    >> my $max = shift @array;
    >> $_ > $max and $max = $_ foreach @array;
    >> print $max;

    >
    > This still yields an answer of 420, which is not in the array.


    See above.

    --
    John Bokma j3b

    Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
    Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
    John Bokma, Feb 21, 2014
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    3
    Views:
    15,668
    Jay B. Harlow [MVP - Outlook]
    Aug 9, 2003
  2. Phil Endecott

    Obj* ptr = new Obj(X)

    Phil Endecott, Jun 3, 2005, in forum: C++
    Replies:
    5
    Views:
    457
    Mark P
    Jun 3, 2005
  3. Shalabh Chaturvedi
    Replies:
    2
    Views:
    440
    Mike C. Fletcher
    Feb 20, 2004
  4. Matthew Thorley

    How do you convert a string obj to a file obj?

    Matthew Thorley, May 4, 2005, in forum: Python
    Replies:
    7
    Views:
    497
    Peter Otten
    May 4, 2005
  5. alf
    Replies:
    9
    Views:
    401
Loading...

Share This Page