Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Seekers of Perl Wisdom

( [id://479]=superdoc: print w/replies, xml ) Need Help??

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
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.
Can't require MCE::Map (Strawberry)?
4 direct replies — Read more / Contribute
by Anonymous Monk
on Mar 07, 2025 at 02:20
    use strict; use warnings; use feature 'say'; use MCE::Map; MCE::Map-> init( chunk_size => 1, max_workers => 4, user_begin => sub { print "## ", MCE-> wid, " started\n"; }, user_end => sub { print "## ", MCE-> wid, " completed\n"; }, ); my @a = MCE::Map-> run( sub { $_ }, [ 0 .. 9 ]); print "\n", "@a", "\n"; say $MCE::VERSION;

    This, of course, prints:

    ## 1 started ## 3 started ## 2 started ## 4 started ## 1 completed ## 3 completed ## 2 completed ## 4 completed 0 1 2 3 4 5 6 7 8 9 1.882

    I want to make dependency on MCE, in my module, very optional i.e. triggered by rare circumstances only. Replacing "use" with "require" results in just first 4 lines of output and process running indefinitely, 4 cores fully loaded.

    MCE::Map being just a convenience, I can do this instead:

    use strict; use warnings; use feature 'say'; require MCE; my @in = ( 0 .. 9 ); my @out; my $mce = MCE-> new( chunk_size => 1, max_workers => 4, user_begin => sub { print "## ", MCE-> wid, " started\n"; }, user_end => sub { print "## ", MCE-> wid, " completed\n"; }, user_func => sub { MCE-> gather( $_ )}, input_data => \@in, gather => \@out, ); $mce-> run; say "@out"; $mce-> shutdown;

    And it runs perfectly. I understand I'll have to deal now with ordering of the output, it's not an issue. But that's the reason I was hoping to use MCE::Map to make it easier. Is this a bug?

    In general, is very optional (documented) dependency on something big and complex as MCE a bad-bad-bad idea? I guess I'll have to indicate minimum required MCE version then, which for example above would be... 1.500?

exit from $SIG{__DIE__} via a loop exit?
3 direct replies — Read more / Contribute
by ForgotPasswordAgain
on Mar 07, 2025 at 00:13
    %SIG says "When a __DIE__ hook routine returns, the exception processing continues as it would have in the absence of the hook, unless the hook routine itself exits via a goto &sub, a loop exit, or a die()". Presumably "continues as it would have in the absence of the hook" means it dies, but what does "the hook routine itself exits via ... a loop exit" mean? Attempts:
    $ perl -Mstrict -wE'$SIG{__DIE__}=sub{last}; die "hi"' Exiting subroutine via last at -e line 1. Can't "last" outside a loop block at -e line 1. # no strict $ perl -wE'$SIG{__DIE__}=sub{last}; die "hi"' Exiting subroutine via last at -e line 1. Can't "last" outside a loop block at -e line 1. # no warnings $ perl -E'$SIG{__DIE__}=sub{last}; die "hi"' Can't "last" outside a loop block at -e line 1. # -e instead of -E $ perl -e'$SIG{__DIE__}=sub{last}; die "hi"' Can't "last" outside a loop block at -e line 1. # put last in a while loop, dies $ perl -e'$SIG{__DIE__}=sub{while(1){last}}; die "hi"' hi at -e line 1. # put last in a non-loop block, dies $ perl -e'$SIG{__DIE__}=sub{{last}}; die "hi"' hi at -e line 1.
    Edit:
    $ perl --version This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-ms +ys-thread-multi
ActiveState to Strawberry?
4 direct replies — Read more / Contribute
by dorianwinterfeld
on Mar 05, 2025 at 13:08
    Greetings Monks -

    I have a client that is thinking of switching from ActiveState Perl to Strawberry Perl. Do you know how heavy a lift this will be?

    Staying with Windows is a requirement. They have over a hundred CGI based apps that use Inline::Java and JDBC for database connectivity.

    Any advice/opinions would be appreciated.

Perl release v5.40.1 on a 32-bit box showing failed tests for atime and ctime in Time::HiRes
2 direct replies — Read more / Contribute
by Intrepid
on Mar 04, 2025 at 21:52

    This time I'll put the question first: "How worried should I be?" I set up a build of the most recent Debian archive of stable perl (v5.40.1) and saw the following failures in Time::HiRes:

    cwd: ~/build/perl/perl-debian-5.40/t
    Ran shell command:
       ./perl harness 2>&1 | egrep --color -i -e 'Fail' -
    Got output:

    -------------------------------------
    # Failed test 'atime set correctly'
    # Failed test 'mtime set correctly'
    # Failed test 'atime set correctly'
    # Failed test 'mtime set correctly'
    # Failed test 'File 1 atime set correctly'
    # Failed test 'File 1 mtime set correctly'
    # Failed test 'File 2 atime set correctly'
    # Failed test 'File 2 mtime set correctly'
    # Looks like you failed 8 tests of 22.
    Failed 8/22 subtests
    ../dist/Time-HiRes/t/utime.t (Wstat: 2048 (exited 8) Tests: 22 Failed: 8)
    Failed tests: 2-3, 5-6, 12-15
    -------------------------------------

    Perl release v5.40.1
    Module packed with Perl: Time::HiRes v1.9777
    Linux version 6.1.0-12-686
    Debian 6.1.52-1 (2023-09-07)

    I looked at http://matrix.cpantesters.org/ but I haven't learned to interpret the test matrix yet (I'm pleading ignorance when really I am probably just too distracted right now).

    Mar 05, 2025 at 02:47 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)


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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others taking refuge in the Monastery: (1)
    As of 2025-12-15 01:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What's your view on AI coding assistants?





      Results (95 votes). Check out past polls.

      Notices?
      hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
      erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.