Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Use of List::Util

by catfish1116 (Sexton)
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 (Archbishop) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2019-10-19 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?