text
stringlengths
0
834k
print STDERR <<EOT;
ppm gui failed: $err
The PPM graphical interface can't be used unless the DISPLAY environment
variable is set up. Either set it to the name of the X server to connect
to or use $PROGNAME as a command line tool.
Run '$PROGNAME help' to learn how to use this program as a command line tool.
EOT
exit 1;
}
if ($err =~ /^Can't locate (Tkx|Tcl)\.pm\b/) {
ppm_log(""ERR"", ""$PROGNAME $CMD: $err"");
$err = clean_err($err);
print STDERR <<EOT;
The PPM graphical interface is not available for this Perl installation.
Run '$PROGNAME help' to learn how to use this program as a command line tool.
EOT
exit 1;
}
die $err;
}
}
sub do_log {
$USAGE = ""log [--errors] [<minutes>]"";
my $errors;
if (@ARGV) {
require Getopt::Long;
Getopt::Long::GetOptions(
'errors' => \$errors,
) || usage();
}
usage() if @ARGV > 1 || (@ARGV && $ARGV[0] !~ /^[1-9]\d*\z/);
my $min = shift(@ARGV) || 1;
my $logfile = ActivePerl::PPM::Logger::ppm_logger()->logfile;
open(my $fh, ""<"", $logfile) || die ""Can't open $logfile: $!"";
print ""Last "", ($min == 1 ? ""minute"" : ""$min minutes""), "" of $logfile"";
print "" errors"" if $errors;
print "":\n\n"";
my @t = (localtime time - $min * 60)[reverse 0..5];
$t[0] += 1900; # year
$t[1] ++; # month
my $ts = sprintf ""%04d-%02d-%02dT%02d:%02d:%02d"", @t;
my $count;
while (<$fh>) {
if ($_ gt $ts .. 1) {
if (!$errors || (/^\S+ <(\d+)>/ && $1 <= 3)) {
print;
$count++;
}
}
}
unless ($count) {
print ""*** No logged events ***\n"";
}
}
sub do_version {
if (@ARGV) {
$USAGE = ""version"";
usage(""The $CMD command does not take arguments."");
}
require ActivePerl::PPM;
print ""ppm $ActivePerl::PPM::VERSION"";
if (defined &ActivePerl::PRODUCT) {
print "" ("" . ActivePerl::PRODUCT() . "" "" . ActivePerl::BUILD() . "")"";
}
print ""\nCopyright (C) 2012 ActiveState Software Inc. All rights reserved.\n"";
}
sub do_help {
if (@ARGV > 1) {
$USAGE = ""help [<subcommand>]"";
usage();
}
my $pod2text = qq(""$^X"" -MPod::Text -e ""Pod::Text->new->parse_from_filehandle"");
my $pager = $ENV{PAGER} || ""more"";
open(my $fh, ""<"", __FILE__) || die ""Can't open "" . __FILE__ . "": $!"";
if (@ARGV) {
my $cmd = shift(@ARGV);
my $foundit;
while (<$fh>) {
if (/^=item B<ppm \Q$cmd\E\b/o) {
$foundit++;
last;
}
}
if ($foundit) {
open(my $out, ""| $pod2text | $pager"");
print $out ""=over\n\n"";
print $out $_;
my $over_depth = 0;
while (<$fh>) {
last if /^=item B<ppm (?!\Q$cmd\E\b)/o;
if (/^=back\b/) {