Marek Novotny <(E-Mail Removed)> 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-ex...for-books.html
> 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-ex...for-books.html
Aucun commentaire:
Enregistrer un commentaire