Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Use of List::Util

by catfish1116 (Beadle)
on Mar 14, 2019 at 15:34 UTC ( #1231263=perlquestion: print w/replies, xml ) Need Help??

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 (Cardinal) 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1231263]
Approved by Athanasius
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2021-02-25 10:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found