What's wrong with my pinto repository? Or with cpanm? (on CygwinPerl)
1 direct reply — Read more / Contribute
|
by Intrepid
on May 17, 2025 at 14:44
|
|
|
Hello impeccable denizens of Perlmonks. I've got a problem with cpanm not finding a module in the list of dependencies for Clipboard(.pm), in my newly created pinto repo. I've pasted the output here (a little bit trimmed of irrelevant stuff):
export REPO="/cygdrive/c/Users/somia/code-repositories/pinto/Clipboard"
$ cpanm --verbose --from "file://$REPO" --install Clipboard
cpanm (App::cpanminus) 1.7047 on perl 5.040002 built for x86_64-cygwin-threads-multi
Work directory is C:/Users/somia/.cpanm/work/1747447503.13337
Written by John Gilmore and Jay Fenlason.
Searching Clipboard on mirror file:///cygdrive/c/Users/somia/code-repositories/pinto/Clipboard ...
Downloading index file file:///cygdrive/c/Users/somia/code-repositories/pinto/Clipboard/modules/02packages.details.txt.gz ...
Uncompressing index file...
--> Working on Clipboard
Fetching file:///cygdrive/c/Users/somia/code-repositories/pinto/Clipboard/authors/id/K/KI/KING/Clipboard-0.13.tar.gz ... OK
Unpacking Clipboard-0.13.tar.gz
Clipboard-0.13/
Clipboard-0.13/scripts/
Clipboard-0.13/scripts/clipjoin
Clipboard-0.13/scripts/clipbrowse
Clipboard-0.13/scripts/clipaccumulate
Clipboard-0.13/scripts/clipedit
Clipboard-0.13/scripts/clipfilter
Clipboard-0.13/README
Clipboard-0.13/t/
Clipboard-0.13/t/mock.t
Clipboard-0.13/t/drivers.t
Clipboard-0.13/META.yml
Clipboard-0.13/inc/
Clipboard-0.13/inc/Module/
Clipboard-0.13/inc/Module/Install.pm
Clipboard-0.13/inc/Module/Install/
Clipboard-0.13/inc/Module/Install/Win32.pm
Clipboard-0.13/inc/Module/Install/Metadata.pm
Clipboard-0.13/inc/Module/Install/WriteAll.pm
Clipboard-0.13/inc/Module/Install/Can.pm
Clipboard-0.13/inc/Module/Install/Makefile.pm
Clipboard-0.13/inc/Module/Install/Fetch.pm
Clipboard-0.13/inc/Module/Install/Base.pm
Clipboard-0.13/INSTALL
Clipboard-0.13/at/
Clipboard-0.13/at/clipbrowse-test
Clipboard-0.13/at/clipfilter-test
Clipboard-0.13/at/pxclip
Clipboard-0.13/at/clipjoin-test
Clipboard-0.13/at/all-xclip-selections
Clipboard-0.13/at/all
Clipboard-0.13/at/run
Clipboard-0.13/lib/
Clipboard-0.13/lib/Clipboard/
Clipboard-0.13/lib/Clipboard/Win32.pm
Clipboard-0.13/lib/Clipboard/MacPasteboard.pm
Clipboard-0.13/lib/Clipboard/Xclip.pm
Clipboard-0.13/lib/Clipboard.pm
Clipboard-0.13/Makefile.PL
Clipboard-0.13/MANIFEST
Clipboard-0.13/Test/
Clipboard-0.13/Test/MockClipboard.pm
Clipboard-0.13/Test/Clipboard.pm
Clipboard-0.13/Changes
Entering Clipboard-0.13
Checking configure dependencies from META.yml
Running Makefile.PL
Configuring Clipboard-0.13 ... Checking if your kit is complete...
Looks good
Warning: prerequisite Win32::Clipboard 0 not found.
Generating a Unix-style Makefile
Writing Makefile for Clipboard
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.74)
Checking if you have Win32::Clipboard 0 ... No
==> Found dependencies: Win32::Clipboard
Searching Win32::Clipboard on mirror file:///cygdrive/c/Users/somia/code-repositories/pinto/Clipboard ...
! Finding Win32::Clipboard (0) on mirror file:///cygdrive/c/Users/somia/code-repositories/pinto/Clipboard failed.
! Couldn't find module or a distribution Win32::Clipboard
! Installing the dependencies failed: Module 'Win32::Clipboard' is not installed
! Bailing out the installation for Clipboard-0.13.
So, the packages in my repository are as follows:
Edit
Investigation shows that Win32::Clipboard is packaged in Clipboard itself. Should this make a difference? Any ideas for how I can make this work as it's supposed to? Is there something about the way the Clipboard package is constructed that is abnormal or problematical?
The problem wasn't in Pinto or in cpanm."Clipboard::Win32" != "Win32::Clipboard", as caught by choroba below.
May 17, 2025 at 18:42 UTC
|
Largest integer in 64-bit perl
8 direct replies — Read more / Contribute
|
by harangzsolt33
on May 16, 2025 at 13:56
|
|
|
my $MAXQUAD = 18446744073709551615; # equals 0xffffffffffffffff
for (my $i = 0; $i <= $MAXQUAD; $i++)
{
printf("\n %f", $i);
}
exit;
Please ignore the fact that this will take forever to count from 0 to $MAXQUAD, but would it actually work? ...because in a 32-bit environment, this loop will never end! It will count from 0 to 9007199254740992, and it will not increment beyond that. It will just get stuck at that number.
|
wrap abbreviations in XML element
1 direct reply — Read more / Contribute
|
by LexPl
on May 16, 2025 at 05:06
|
|
|
I have got a highly complex, nested XML document in encoding ISO-8859-1 which contains abbreviations.
Each abbreviation has two to three letters and each letter is directly followed by a full stop. The separator between each letter plus full stop might be
- !!!emsp14;
- !!!hairsp;
- \s
- nothing!
You could define this as a regex: a-zA-Z\.((!!!emsp14;|!!!hairsp;|\s)?a-zA-Z)+
I would like to wrap each abbreviation into an element <abbrev> and unify the separator whitespace to "!!!hairsp;"
This looks pretty easy, but there are some nasty pitfalls: If two abbreviations are adjacent to each other, the problem of proper segmentation pops up. For example the string "a. A. z. B." could lead to <abbrev>a.!!!hairsp;A.!!!hairsp;z.</abbrev> which doesn't exist. The correct solution would be <abbrev>a.!!!hairsp;A.</abbrev>_<abbrev>z.!!!hairsp;B.</abbrev> where the underscore stands for a space.
Another issue is the full stop at the end of a sentence and a following abbreviation: "Hier müssen die richtigen Regeln einbezogen werden. Z.B. ist hier § 42 ...". Of course, there exists no abbreviation "n. Z.B.", but the proper tagging would be: "Hier müssen die richtigen Regeln einbezogen werden. <abbrev>Z.!!!hairsp;B.</abbrev> ist hier § 42 ...".
As the regex captures abbreviations with 2 letters and with 3 letters, it has to be taken care that a 3 letter abbreviation such as "m.w.N." won't be split into a two letter abbreviation "m.w." followed by "N."
I suppose that you will need a kind of knowledge base in your script for the proper segmentation, but I don't know how to do that.
The easy solution would be a bunch of changes:
!/usr/bin/perl
use warnings;
use strict;
# for interactive mode
my $infile = $ARGV[0];
my $outfile = $ARGV[1];
open(IN, '<' . $infile) or die $!;
open(OUT, '>' . $outfile) or die $!;
while(<IN>)
{
# wrap "a.A."
$_ =~ s[a\.!!!hairsp;A\.](<abbrev n='2'>a.!!!hairsp;A.</abbrev>)g;
$_ =~ s[a\.!!!emsp14;A\.](<abbrev n='2'>a.!!!hairsp;A.</abbrev>)g;
+
$_ =~ s[a\.\sA\.](<abbrev n='2'>a.!!!hairsp;A.</abbrev>)g;
$_ =~ s[a\.A\.](<abbrev n='2'>a.!!!hairsp;A.</abbrev>)g;
# wrap "a.F."
$_ =~ s[a\.!!!hairsp;F\.](<abbrev n='2'>a.!!!hairsp;F.</abbrev>)g;
$_ =~ s[a\.!!!emsp14;F\.](<abbrev n='2'>a.!!!hairsp;F.</abbrev>)g;
+
$_ =~ s[a\.\sF\.](<abbrev n='2'>a.!!!hairsp;F.</abbrev>)g;
$_ =~ s[a\.F\.](<abbrev n='2'>a.!!!hairsp;F.</abbrev>)g;
# wrap "d.h."
$_ =~ s[d\.!!!hairsp;h\.](<abbrev n='2'>d.!!!hairsp;h.</abbrev>)g;
$_ =~ s[d\.!!!emsp14;h\.](<abbrev n='2'>d.!!!hairsp;h.</abbrev>)g;
+
$_ =~ s[d\.\sh\.](<abbrev n='2'>d.!!!hairsp;h.</abbrev>)g;
$_ =~ s[d\.h\.](<abbrev n='2'>d.!!!hairsp;h.</abbrev>)g;
# wrap "D.h."
$_ =~ s[D\.!!!hairsp;h\.](<abbrev n='2'>D.!!!hairsp;h.</abbrev>)g;
$_ =~ s[D\.!!!emsp14;h\.](<abbrev n='2'>D.!!!hairsp;h.</abbrev>)g;
+
$_ =~ s[D\.\sh\.](<abbrev n='2'>D.!!!hairsp;h.</abbrev>)g;
$_ =~ s[D\.h\.](<abbrev n='2'>D.!!!hairsp;h.</abbrev>)g;
print OUT $_;
}
close(IN);
close(OUT);
Do you see a more efficient solution? And if yes, could you kindly show me how this would look like?
|
Perl Best Practices -- 20 years later
4 direct replies — Read more / Contribute
|
by pfaut
on May 13, 2025 at 07:26
|
|
|
I've been browsing through the monastery using Random Node. I keep coming across references to Perl::Critic. I downloaded it and ran it against some of my perl code.
Perl::Critic seems to base most if its policies on recommendations from Perl Best Practices. I was intrigued as to the rationale behind many of the policies. There is some documentation within the policy files themselves but I thought it might be useful to have the book. I searched for the book and found it was written in 2005 and hasn't been updated.
How relevant is this book 20 years later? The current version at the time of publication was 5.8. Perl has seen many changes over the last 20 years. Do the book's recommendations still apply? Is there much that's outdated due to new features in the language?
I'll probably buy the book anyway since it does appear to contain a lot of wisdom. I'm just curious how much material would need rewriting if a new edition were to be published today based on perl 5.40.
| 90% of every Perl application is already written. ⇒ | | dragonchild |
|
Basic question about Iterator code
2 direct replies — Read more / Contribute
|
by adamsj
on May 12, 2025 at 10:11
|
|
|
I've been working through examples in MJD's Higher Order Perl and hit a snag. This code from Chapter 4 works fine:
# This software is Copyright 2005 by Elsevier Inc. You may use it
# under the terms of the license at http://perl.plover.com/hop/LICENSE
+.txt .
###
### upto
###
## Chapter 4 section 2.1
sub upto {
my ($m, $n) = @_;
return sub {
return $m <= $n ? $m++ : undef;
};
}
my $it = upto(3,5);
my $value->it();
print "$value\n";
However, when I sweeten the function as suggested in the text:
sub upto {
my ($m, $n) = @_;
return Iterator {
return $m <= $n ? $m++ : undef;
};
}
sub Iterator (&) { return $_[0]; }
I get a failure:
Undefined subroutine &main::3 called
They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen
|
Applying logical operators in either complex SQL xor hashes?
3 direct replies — Read more / Contribute
|
by mldvx4
on May 10, 2025 at 08:01
|
|
|
Greetings, PerlMonks,
Thanks for DBI. It works very well with SQLite3. I have a short (for now) Perl script which is accessed via CGI::Fast which will soon have a small but varying number of SQL queries for SQLite3. The queries are targeted at various FTS5 tables. The number of queries is between 1 and n where n is a "small" number, but in any case changing each time. They are executed theough prepare and execute statements. The results from each query are collected by the Perl script into its own hash with the records' unique key (recno) as the hash key. For illustration, here is the basic sample query:
SELECT old_keys.recno AS recno,
'http://example.org/' || old_keys.file,
old_metadata.value AS title
FROM old_keys
JOIN old_metadata
ON old_keys.recno = old_metadata.recno
WHERE term='dc.title' AND old_metadata.recno
IN (
SELECT rowid AS recno
FROM old_fts5_metadata
WHERE old_fts5_metadata MATCH ?);
When there is more than one query, there will be an operator XOR, AND, OR, or NOT applied between them.
My question is about the recommended approach, should I apply the operators to the various hashes after separate queries, or should I have the script build out more complex queries into a single SQL query for each search?
|
What's the best way to ask about code from an older book?
3 direct replies — Read more / Contribute
|
by adamsj
on May 09, 2025 at 16:00
|
|
|
|
|
Strange Occurrence in Substitution Statement
1 direct reply — Read more / Contribute
|
by roho
on May 06, 2025 at 14:50
|
|
|
I have paired the problem down as much as possible. In the SSCCE below I am removing placeholder backticks between date and time (the reason for this lies in complete program). I am also removing extra spaces in the text (again, the reason for this lies in the complete program). When there is no extra space to remove the "$extra" variable contains the empty string, which I explicitly set to the empty string to recreate the error condition in the SSCCE.
The problem is the second and subsequent lines have the backtick removed (i.e., replaced with nothing), while the first line is processed as expected where the backtick is replaced by a single space.
It appears the substitution of "$extra" is taking out the backticks (for data lines 2 and following) before the following substitution replaces backticks with a single space. It's a mystery why only the first data line is processed correctly.
#!/usr/bin/perl
use strict;
use warnings;
while ( <DATA> ) {
chomp;
my $fname = $_;
print qq(\nBefore: $fname\n);
my $extra = '';
$fname =~ s/$extra//;
$fname =~ s/`/ /;
print qq( After: $fname\n);
}
exit;
__DATA__
2025-05-05`09:22:00 7,674 -rw-rw-rw- C:\~Zipfile\H\Helpin
+gHand\Software\DevTools\.edit.current
2025-05-05`09:22:00 7,674 -rw-rw-rw- C:\PerlApps\H\Helpin
+gHand\Software\DevTools\.edit.current
2025-05-05`09:22:00 5,448 -rw-rw-rw- C:\~Zipfile\B\Bat\pi
+cs\.edit.current
"It's not how hard you work, it's how much you get done."
|
Resource Not Found error
1 direct reply — Read more / Contribute
|
by StorminN61
on May 05, 2025 at 13:48
|
|
|
Recently copied a Perl script to a new server since old one is no longer in compliance. When I run the script on the old server, it creates a text file, aka trigger file, which is used by IBM Workload Scheduler to start processing a particular job. Depending on the trigger file, IWS determines which job should run. I copied the directory structure on the new server, made the IIS entries on the new server match what is on the old server, but when I try to create the triggers, I get the 404 Resource not found error, with no further information as to what resource it is specifically missing.
#!/usr/bin/perl -w
use CGI;
print "Content-type: text/html\n\n";
print "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"tex
+t/html; charset=iso-8859-1\" />\n";
print "<link rel=\"stylesheet\" href=\"http://pctldocs/doc_style.css\"
+ type=\"text/css\" />\n";
print "<title>Trigger Result</title>\n</head>\n";
print "<body>\n";
print "Result:<br />";
my @query = split(/=/, $ENV{'QUERY_STRING'});
my $term = $query[$#query];
my $file = 'd:\\apps\\AETrigger\\' . $term . '.txt';
if (open (FH, '>', $file)) {
print "Trigger for $term ($query[0]) has been created.";
} else {
print "Error creating trigger; please contact support.";
}
print "</body>\n</html>";
|
Cannot Remove Redefined Warnings
4 direct replies — Read more / Contribute
|
by Sukhster
on May 05, 2025 at 11:41
|
|
|
Hi,
I have recompiled Perl from Source (v5.40.2) with DBI (DBI-1.647.tar.gz) and DBD-Oracle (DBD-Oracle-1.90.tar.gz) - and am now getting redefined errors for the first time.
Was previously on v5.38.0 with DBI (DBI-1.643.tar.gz) and DBD-Oracle (DBD-Oracle-1.83.tar.gz) and didn't face this issue.
I would like to keep warning - and either resolve these warnings, or remove them.
I have tried the following, but to no avail. I still get the defined warnings.
- use warnings qw(-refine);
- no warnings qw(redefine);
- no warnings 'redefine';
Any advice, Ye Great Monks of Perl?
########################
# Declare Modules
########################
use strict;
use warnings;
# Other Modules
use POSIX qw(strftime);
use Time::HiRes qw(time);
use Time::Piece;
use Time::Seconds;
no warnings 'redefine';
use DBI;
use DBD::Oracle qw(:ora_types :ora_fetch_orient :ora_exe_modes);
. . . .
sub connect_to_database($$$)
{
# Declare the variables
my ($db_uid, $db_pwd, $db_sid) = @_;
my $dbh;
my %attribs = (
PrintError => 0,
AutoCommit => 0,
RaiseError => 0
);
$dbh = DBI->connect("DBI:Oracle:".$db_sid, $db_uid, $db_pwd ,
+\%attribs )
or die "ERROR: Can't connect to database ($db_uid\@$d
+b_sid): ".$DBI::errstr."\n";
return $dbh;
}
Subroutine DBI::db::ora_lob_read redefined at /applications/app12345/A
+PP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DBI
+.pm line 1398.
Subroutine DBI::db::ora_lob_write redefined at /applications/app12345/
+APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DB
+I.pm line 1398.
Subroutine DBI::db::ora_lob_append redefined at /applications/app12345
+/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/D
+BI.pm line 1398.
Subroutine DBI::db::ora_lob_trim redefined at /applications/app12345/A
+PP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DBI
+.pm line 1398.
Subroutine DBI::db::ora_lob_length redefined at /applications/app12345
+/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/D
+BI.pm line 1398.
Subroutine DBI::db::ora_lob_chunk_size redefined at /applications/app1
+2345/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-mul
+ti/DBI.pm line 1398.
Subroutine DBI::db::ora_lob_is_init redefined at /applications/app1234
+5/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/
+DBI.pm line 1398.
Subroutine DBI::db::ora_nls_parameters redefined at /applications/app1
+2345/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-mul
+ti/DBI.pm line 1398.
Subroutine DBI::db::ora_can_unicode redefined at /applications/app1234
+5/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/
+DBI.pm line 1398.
Subroutine DBI::db::ora_can_taf redefined at /applications/app12345/AP
+P_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DBI.
+pm line 1398.
Subroutine DBI::db::ora_db_startup redefined at /applications/app12345
+/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/D
+BI.pm line 1398.
Subroutine DBI::db::ora_db_shutdown redefined at /applications/app1234
+5/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/
+DBI.pm line 1398.
Subroutine DBI::st::ora_fetch_scroll redefined at /applications/app123
+45/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi
+/DBI.pm line 1398.
Subroutine DBI::st::ora_scroll_position redefined at /applications/app
+12345/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-mu
+lti/DBI.pm line 1398.
Subroutine DBI::st::ora_ping redefined at /applications/app12345/APP_H
+OME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DBI.pm
+line 1398.
Subroutine DBI::st::ora_stmt_type_name redefined at /applications/app1
+2345/APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-mul
+ti/DBI.pm line 1398.
Subroutine DBI::st::ora_stmt_type redefined at /applications/app12345/
+APP_HOME/apps/perl5/lib/site_perl/5.40.2/x86_64-linux-thread-multi/DB
+I.pm line 1398.
|