#!/usr/bin/env perl use strict; use warnings; use constant { BASE_URL => 'https://www.example.com/reg/', LS => '/usr/bin/ls', LS_OPTS => [qw{-l -h}], }; use IPC::System::Simple 'capturex'; die "Usage: $0 dir\n" unless @ARGV; my $dir = $ARGV[0]; my $base_dir = '/home/ken/tmp/pm_11147164_web_dir_listing/'; my $dir_path = $base_dir . $dir; die "ERROR: User '$dir' does not exist.\n" unless -e $dir_path && -d _; chdir $base_dir; my @listing; for (capturex(LS, @{+LS_OPTS}, $dir_path)) { next if 0 == index $_, 'total'; /^(.*?\s)(\S+)$/; push @listing, qq{
User: $dir
\n"; if (@listing) { print "User '$dir' has no files.
\n"; }