Aitor Ramos Pajares
Aitor Ramos Pajares

Reputation: 361

How do I fix the undefined subroutine main error

I am using the CPAN Unix::Passwd::File module, and when a I use any of its functions, the script throws the error: Undefined subroutine &main

For example, for get the max uid:

#!/urs/bin/perl
use Unix::Passwd:File;

my $res = get_max_uid();

the error is Undefined subroutine &main::get_max_uid called at scriptname.pl line 4

Upvotes: 1

Views: 1992

Answers (1)

toolic
toolic

Reputation: 62096

A quote from the docs:

This function is not exported by default, but exportable.

Try:

my $res = Unix::Passwd:File::get_max_uid();

or:

use Unix::Passwd:File qw(get_max_uid);

Upvotes: 6

Related Questions