http://qs321.pair.com?node_id=1231263

catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a simple script that grabs the largest number from a list. I am trying out the List::Util function and am getting an error. Below is code and error

#! /usr/bin/perl use v5.16; use warnings; use List:: Util qw(max); ############# ## 03/14/19 ## Program utilizes List::Util function my $max = max( 55, 101, 3, 983, 17, 45, 8744, 2) print " This is the largest $max \n"; syntax error at ./Page_290 line 4, near "Util qw(max)" syntax error at ./Page_290 line 11, near ") print" Execution of ./Page_290 aborted due to compilation errors

TIA the catfish

~

Replies are listed 'Best First'.
Re: Use of List::Util
by LanX (Saint) on Mar 14, 2019 at 15:36 UTC
    > List:: Util qw

            ^ (Space)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: Use of List::Util
by dasgar (Priest) on Mar 14, 2019 at 16:48 UTC

    LanX pointed out the source of the problem for the first syntax error message regarding line 4.

    The second syntax error message about line 11 (the my $max line) is due to missing a semi-colon at the end of the line.