If
you have a question on how to do something in Perl, or
you need a Perl solution to an actual real-life problem, or
you're unsure why something you've tried just isn't working...
then this section is the place to ask.
However, you might consider asking in the chatterbox first (if you're a
registered user). The response time tends to be quicker, and if it turns
out that the problem/solutions are too much for the cb to handle, the
kind monks will be sure to direct you here.
I'm getting an unexpected result from an attempt to use a module,
Filesys::DfPortable, on CPAN. I'm seeing the
same results in blocks, with different filesystems used as arguments to
dfportable. The output of my code looks like this:
$ perl ~/Documents/perl-libdirs-installTime.pl
/usr/lib/perl5/5.40/x86_64-cygwin-threads installarchlib
Total 1k blocks used in installarchlib: 175,087,368
/usr/share/perl5/5.40 installprivlib
Total 1k blocks used in installprivlib: 175,087,368
So here's the code I'd like help with:
#!/usr/bin/env perl
#
use strict;
use warnings;
use Config;
use Number::Format qw(:subs);
use Filesys::DfPortable;
my $mlen = 0;
my %hop;
my @lodirs = qw(installarchlib installprivlib);
for (@lodirs) {
my $p = $Config{ $_ };
$mlen = length( $p ) > $mlen ? length( $p ) : $mlen;
$hop{ $_ } = $p;
}
$mlen += 2;
for (sort keys( %hop )) {
printf( "%-${mlen}s%s\n", $hop{ $_ }, $_ );
my $mea = dfportable( $hop{ $_ }, 1024 );
printf "Total 1k blocks used in %s: %s\n",
$_ , format_number( $mea->{bused} );
}
I started working on this little script in Linux and I see the same anomalous results on CygPerl. I don't think it's a PEBKAC but I need other eyes to check it out. Thanks very much, Monks / Nuns.
– Soren
Mar 10, 2026 at 21:22 UTC
A just machine to make big decisions
Programmed by fellows (and gals) with compassion and vision
We'll be clean when their work is done
We'll be eternally free yes, and eternally young Donald Fagen —> I.G.Y. (Slightly modified for inclusiveness)
I have a module A that overloads the '-' operator via its A::oload_minus() subroutine.
And I have a second module B that also overloads the '-' operator via it's own B::oload_minus() subroutine.
Both modules also have their own oload_add, oload_mul, oload_div, oload_mod and oload_pow subroutines that overload the other basic arithmetic operators).
I have constructed the overloading in module A to handle B objects.
But if module B's overloading subroutines are passed a module A object, it is (by my current design) a fatal error.
use A;
use B;
$A_obj = A->new(16);
$B_obj = B->new(6);
my $n1 = $A_obj - $B_obj; # $n1 is an A object with value 10
my $n2 = $B_obj - $A_obj; # Fatal error
In the above demo I want $n2 to be an A object, with the value of -10.
That is, I want the A::oload_minus() sub to receive the args ($A_obj, $B_obj, TRUE).
Instead, the B::oload_minus() sub is receiving the args ($B_obj, $A_obj, FALSE) - which is, by my current design, a fatal error since B::overload_minus() does not currently accept A objects.
Is there a way that I can work around this without making any changes to the B module ? (The motivation to not alter module B is simply that I don't want to add more clutter to B unless I need to.)
My module "A" is in fact Math::MPC, and my module "B" is in fact Math::MPFR.
AFTERTHOUGHT: I should point out that the arithmetic overloading in the publicly available versions of Math::MPC don't yet accept Math::MPFR objects. (I've currently implemented this new feature on my local Math::MPC builds only.)
I have a class that uses the types as a union, this or that
package MyApp;
use v5.34;
use warnings;
use Moo;
use Types qw/ InvoiceType CreditType /;
has 'type' => (
is => 'ro',
isa => InvoiceType | CreditType,
required => 1,
coerce => 1,
);
sub run {
my ($self) = @_;
say "Running with ".$self->type;
}
1;
t/type.t ..
# Subtest: Type coercion
ok 1 - Can coerce a sales invoice
ok 2 - Can coerce a supplier invoice
ok 3 - Can coerce a credit type
ok 4 - Can coerce a supplier credit type
1..4
ok 1 - Type coercion
ok 2 - use MyApp;
# Subtest: Class coercion
# Type=Invoice
ok 1 - An object of class 'MyApp' isa 'MyApp'
# Type=SupplierInvoice
ok 2 - An object of class 'MyApp' isa 'MyApp'
# Type=Credit
not ok 3 - MyApp->new() died
# Failed test 'MyApp->new() died'
# at t/type.t line 31.
# Error was: Undef did not pass type constraint "InvoiceType|
+CreditType" (in $args->{"type"}) at /home/dpaikkos/spl/local/lib/perl
+5/Test/More.pm line 741
# "InvoiceType|CreditType" requires that the value pass "Credi
+tType" or "InvoiceType"
# Undef did not pass type constraint "InvoiceType"
# "InvoiceType" is a subtype of "Enum["ACCPAY","ACCREC"]"
# "Enum["ACCPAY","ACCREC"]" requires that the value is def
+ined
# Undef did not pass type constraint "CreditType"
I excel at leaving typos in my code but I am pretty sure there are none in the code so far. The coercions appear to work in a stand alone fashion but when used as a union, the 2nd Type does not appear to apply the coercion. If I swap the "CreditType" to be the first item, I find that the InvoiceType fails.
I suspect I could use some kind of named parameterized coercion and `plus_coercions` but I hit this snag and haven't been able to move forward.
Does anyone have any insights into what I'm doing wrong?
Greetings Monks,
I am running strawberry perl 5.30 under windows 11.
When the program below reaches the start function, it fails with the seemingly nonsensical error "Can't locate auto/Tk/ROText/FILENO.al". Tieing only STDOUT to the same widget is no problem.
Does anyone have any insight as to what is happening here?
use warnings;
use strict;
use IPC::Run qw(start pump finish timeout);
use Tk;
require Tk::ROText;
my $mw = MainWindow->new(-title => " NON BLOCKING");
my $outw = $mw->Scrolled('ROText',
-font => "{Courier New} 10 bold",
-background => 'DarkBlue',
-foreground => 'OldLace',
-scrollbars => 'se',
-wrap => 'none',
-width => 100,
-height => 10,
)->pack(-fill => "both", -expand => 1);
+
# tie *STDOUT, 'Tk::Text', $outw;
tie *STDERR, 'Tk::Text', $outw;
my ($in, $out, $err) = ('', '', '');
my $h;
if (! defined(eval { $h = start ['cmd.exe', '/c', 'dir'], \$in, \$out,
+ \$err; }))
{
print "\nStart failed: $@\n";
}
while($h->pumpable)
{
$h->pump;
print $out;
$out = '';
}
$h->finish;
MainLoop;
Dear Monks, here monk Dominik, asking my siblings for wisdom.
I'm a fan of using pp to make standalone programs since v5.40.0, because it lets me use the new Perls and doesn't mess the target system by installing anything by sudo cpan somewhere nobody is finding things again or making updates at all.
Long story short: Delivering a pp archive is already pretty neat, but I'd like to go a step further. The application extracts itself to /tmp/par-<user name hash>/cache-<app hash or -T string> (or similar) by default. So, what I thought, to reduce the startup time, which is really poor for pp executables, compared to native Perl, I'd like to omit the extraction and verification step of the pp binary, but directly start the interpreter from the /tmp/par-.../cache-... directory, with the script as argument. Something I think the pp binary is doing.
But the executables and libraries have very obscure names, so I don't know, what exact I need to execute to start up the interpreter from /tmp/par-.../cache-...
Maybe I'm completely wrong on this path anyway and this is any magic within the pp binary itself, not just from this folder.
So, what I actually try to achieve is: having a unpacked Perl interpreter, running my scripts, for example:
package FOO;
use strict;
use warnings;
sub foo {
my $str = shift;
return $str if $str =~ /^ssh\@github-/;
}
1;
__END__
=head1 NAME
Foo - The great Foo module
What's going on here? I would expect a POD renderer not to look at the active code at all. Is there perhaps a hidden feature that I'm conflicting with here?
I accidentally typed perl v in the terminal and saw a strange message. I tried every letter and found that they all say something like Can't open perl script "z": No such file or directory
except four special letters do something different does anyone know why?
perl a
(nothing happens)
perl b
(nothing happens)
perl c
Unrecognized character \xCF; marked by <-- HERE after <-- HERE near co
+lumn 1 at c line 1.
perl v
Number found where operator expected (Do you need to predeclare "perl"
+?) at v line 2, near "perl 5"
syntax error at v line 2, near "perl 5"
Execution of v aborted due to compilation errors.