http://www.perlmonks.org?node_id=479

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.

Post a new question!

User Questions
Integration with 64 Bit Office installs
1 direct reply — Read more / Contribute
by v705Cas
on Mar 21, 2025 at 11:08

    Hi all,

    For my sins, I run a legacy 5.24 install on which I have built an app of 15 years standing. Recently I have discovered that my Microsoft Outlook integration needed to send scheduled emails breaks on Windows boxes with 64 bit Office installs, while it runs fine with 32 bit Office installs.

    The exact error thrown is:

    No type library matching "Microsoft Outlook" found at ../Perl/lib/Mail +/Outlook.pm line 111

    While there do appear to be plenty of people who've encountered this issue, I do have some constraints which is why their solutions might not apply to my situation. First, I am unfortunately not open to upgrading my installation. Given enough time, I'd love to do that but there's never enough time, especially when there are tight deadlines! Second, I do not have the ability to directly manually tinker with the Registry settings on the machines this application must run on, as local admin rights are locked down.

    I'm definitely not afraid though of tinkering with the modules. There are no external dependencies I have to satisfy so it is my private playground to hack around as I like with.

    Question: How would I go about finding the exact changes needed at the Module level (or even as calls in my code) to address this issue? I've taken a good look around the Meta CPAN site but am none the wiser (all I can see is file permission and version bumps). I still want the application to run with 32 bit Office installs as well as 64 bit Office installs.

    Many thanks in advance!

    Andrew

Perl Tk on a Mac
1 direct reply — Read more / Contribute
by choroba
on Mar 19, 2025 at 09:13
    Hi all,

    I need to install our huge Perl/Tk application on a MacBook. It worked years ago, we even used a signed package so the users weren't supposed to do anything advanced like compiling C libraries themselves. Unfortunately, the old installer doesn't work anymore.

    Does anyone know how to install Perl/Tk an a MacBook? A manual way is enough for now, I'll try to find a way to automate it later.

    Google finds lots of guidelines but most of them seem rather dated.

    I hope it would be easier than rewriting all those several hundred thousand lines to a different GUI.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Is there a definitive module for efficiently searching a collection of text files?
4 direct replies — Read more / Contribute
by nysus
on Mar 18, 2025 at 06:24

    I’m writing a utility to go through my personal perl lib to ensure consistency across files. For example, I will use it to check each file has a comment containing the file’s path. So the utility will be going through and repeatedly searching a lot of text files.

    There will be hundreds of documents searched repeatedly for certain strings of text. Rather than reinvent the wheel, I hunted around for a module that would help ensure the search was done efficiently both in terms of time and resources used so I don’t have to burden myself with worrying about the many small details. For example, the easiest thing for me to do would be to load all files into memory and simply search, write them back out to disk, load them all back into memory, search, save, repeat. Though this is easy, it’s obviously not efficient and I was hoping to find a module that would smartly determine how to handle this problem.

    But I have searched around a bit and have come up empty. Does anyone have any recommendations?

    $PM = "Perl Monk's";
    $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
    $nysus = $PM . ' ' . $MC;
    Click here if you love Perl Monks

Adding regex filters from command-line options
1 direct reply — Read more / Contribute
by Anonymous Monk
on Mar 17, 2025 at 15:10
    I have a command-line download tool that extracts a list of filenames/urls upon which to operate. I added support to filter the list by accepting regex strings from --accept and --reject options. What I have works, but feels off because of the string eval. Is there another approach to this?
    GetOptions( 'accept|a=s' => \my @accept, 'reject|r=s' => \my @reject, ) or die "Error with options\n"; my @filter = map eval "sub { \$_[0] =~ /$_/ }", @accept; push @filter, map eval "sub { \$_[0] !~ /$_/ }", @reject; # my @input = ([url, filename], ...); my @filtered = filter(@input); sub filter { return unless @filter; return map $_->[0], grep { my $f = $_; all { $_->($f->[1]) } @filter } @_; }
LWP::Protocol::https is installed but pinto fails with "Protocol scheme https is not supported"
2 direct replies — Read more / Contribute
by Intrepid
on Mar 16, 2025 at 21:54

    I'm going to go ahead and ask for help even though I know the problem may be a fubar'd system. I'm setting up pinto and am trying my first "pull" from CPAN, and getting an error:

    Failed to mirror https://cpan.perl.org/modules/02packages.details.txt.gz: 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed)

    Thing is, LWP::Protocol::https certainly is installed, as are the dependencies Net::SSLeay and IO::Socket::SSL. Is it something pinto is doing, manipulating @INC or otherwise causing this failure?

    Thank you again (I seem to post in SoPW once a week these days!), good Monks.

    Mar 17, 2025 at 01:50 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)

Behaviour of int() unexpected
7 direct replies — Read more / Contribute
by ceade1000
on Mar 10, 2025 at 17:05

    Maybe it is late, maybe I am tired, but what the fiddley-doo is up with this:

    $ perl -e 'my $val = 8.95; printf("%d\n", int($val * 100));' 894

    Or this for that matter:

    $ perl -MPOSIX -e 'my $val = 8.95; printf("%d\n", POSIX::floor($val * +100));' 894

    So in desperation:

    $ perl -e 'my $val = 8.95; my $mval = $val * 100; printf("%d %d %f %d +%f\n", int($val * 100), $val * 100, $val * 100, $mval, $mval);' 894 894 895.000000 894 895.000000

    It looks like maybe the %d in printf is rounding. But why does it round 895.000000 to 894?

    What exactly is going on here?

Web user account module?
2 direct replies — Read more / Contribute
by Yidd
on Mar 10, 2025 at 15:34
    I'm looking for a Perl module making it easy to implement a Web-based system where user can create accounts, changing passwords, recovering, etc. Any recommendations?
Regex for matching URLs with username/password and token
5 direct replies — Read more / Contribute
by Anonymous Monk
on Mar 10, 2025 at 05:42
    I am looking for a Perl regex pattern that can match URLs in the format where either a token is provided or both a username and password are provided after the server URL. For example:
    1. --server api.blr-ocp1.lab.rbbn.com --username mgore --password abc1 +23 2. --server api.blr-ocp1.lab.rbbn.com --token kfjshdssahdvkbvjkbj
    The regex should be able to capture these variations and extract relevant parts like the server URL, username, and password or token. Any guidance or examples would be greatly appreciated.
CGI simple but frustrating fault
2 direct replies — Read more / Contribute
by gsd4me
on Mar 09, 2025 at 09:49

    Dear all, Not being an expert in new-fangled technology ("what do you mean, I'm not allowed to use assembly code?") I am trying to write a .cgi module to handle a form's data. (Primarily using a perl reference book, but that is by the by). My understanding is that I can write a cgi module to create AND handle data from a form. So I did, but I am having trouble making the (software) decision as to how to progress upon code execution. Please note that it is for historical reasons that I use HTML::Tiny and not CGI but that is not part of the problem, unless corrected here

    # Start the page and form creation process as required $co = HTML::Tiny->new( mode => 'html' ); if ($co->param()) { #data returned from the form submission print "data present - to be analysed\n"; $buffer = ""; if($ENV{'REQUEST_METHOD'} eq "POST") { # POST method retrieves data by the READ command print "POST read\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { # GET method retrieves by accessing the relevant environment v +ariable print "Query String\n"; $buffer = $ENV{'QUERY_STRING'}; } print ("buffer=<p>$buffer</p>"); if (length ($buffer) > 0) { # Analyse the form data .... } else { print "<p>buffer size is zero<p>"; exit; } } else { # No data passed to here by a submit - create the display form tha +t is required to do so print "no data present -to display form\n"; displayForm(); }

    When I run this code (on a server) I get the diagnostics saying that there is "data present - to be analysed" (as if this call is to handle the form data) but then in the next breath the diagnostics say that the "buffer size is zero". I had a minor thought that the data was somehow being 'retained' somewhere and each time that I ran the script, the 'retained' data was being retested. SO I shut everything down overnight, re-running in the morning, but the same 'problem' presents itself

    Q: What is the failing in my software logic here? Have I misread/misunderstood/misinterpreted what I have read in my perl book? As always any help from the monastery would be gratefully received.

    Regards ADB

Bezier curves to circular arcs
1 direct reply — Read more / Contribute
by merrymonk
on Mar 08, 2025 at 08:23
    I have Bezier curves which I want to approximate with circular arcs. Does anyone know how best to do this with Perl? For example I wondered if there were any 'standard' functions or modules that would help.

Add your question
Title:
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.