I'm trying to return the list of Unix users on this perl script. I'm using the Mojolicious framework with Passwd::Unix.
References:
- Mojolicious (http://metacpan.org/pod/Mojolicious)
- Passwd::Unix (http://metacpan.org/pod/Passwd::Unix)
That's my code:
test.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
use Passwd::Unix;
# Instance
my $pu = Passwd::Unix->new();
get '/' => sub {
my $self = shift;
my $users = $pu->users;
$self->stash(
users => $users
);
} => 'test';
app->start;
__DATA__
@@ test.html.ep
<ul>
<% foreach my $user ($users) { %>
<li><%= $user %></li>
<% } %>
</ul>
But instead of returning users, it prints only the total number of users.