Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

Donations gladly accepted

  • (Sep 10, 2018 at 22:53 UTC) Welcome new users!
If you're new here please read PerlMonks FAQ
and Create a new user.

New Questions
circular area in a coordinates grid (AoA)
5 direct replies — Read more / Contribute
by Discipulus
on Mar 19, 2019 at 17:34
    Hello monks,

    I have an array of arrays full of o and, given the coordinates of one element and a radius I want to change all elements around the center into x

    My AoA can be eventually big so I do not want to process every element of the AoA.

    The sub ( illuminate in the example below ) must not complain if a point is outside of the AoA (for example giving a corner as vertex).

    A pure perl solution will be the best, but also using modules will be ok.

    Sorry if I only have the below sketch but I'm very scarce in trig and until now I can only figure to hardcode series of coordinates relative to the vertex (that is silly..)

    use strict; use warnings; my $max = 19; my @aoa = map { [ ( 'o' ) x ($max + 1) ] } 0..$max ; display( @aoa ); # @to_change will contain [row1,col1],[row2,col2]... my @to_change = illuminate( 5, 4, 6 ); sub illuminate{ my $center_row = shift; my $center_col = shift; my $radius = shift; ... } sub display{ foreach my $row ( @_ ){ foreach my $col ( @$row ){ print $col; } print "\n" } }



    PS the above code displays the AoA before the change: I want to be able to select into @to_change the serie of elements falling inside the circle.

    minor changes to explain better

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
mod_perl sharing modules with other accounts when I don't want it to
1 direct reply — Read more / Contribute
by ultranerds
on Mar 19, 2019 at 11:05
    FYI I have already posted this on SO, but not had any replies yet:

    I'm hoping people here will be more knowledgeable :) Rather than repeating everything I posted on the other forum, I won't put too much.

    Basically the issue I'm having is that mod_perl is sharing modules from one <VirtualHost> to another (and I don't want this). I was reading that doing something like this should partition it:

    PerlOptions +Clone PerlSwitches -Mlib=/home/steampunkcom/web/

    ...but while mod_perl works, it still shares the modules :/ Am I missing something?


Linux::usermod - user name ... already exists
1 direct reply — Read more / Contribute
by mldvx4
on Mar 19, 2019 at 03:06

    The following changes the account name just fine except that it also produces an error "user name ... already exists ... at line ...". Just to be clear, the old name changes to the new name in /etc/passwd when the script is run, but it produces an error while doing so. What is the correct way to use Linux::usermod so that no error is produce when changing the account name?

    sub rename_account { my ($name,$nname) = (@_); my $account = Linux::usermod->new($name); $account->set('name'=>$nname); }

    Perhaps it is a misunderstanding in how to use Linux::usermod. Looking at the manual page, that looks like the correct usage. So perhaps I have read and interpreted it incorrectly.

    Edit: The problem seems related to /etc/shadow which seems like it is not updated. So if one changes back and forth between the same two names, the first change goes through but leaves the old name in /etc/shadow so the second attempt fails because the old name is still their. I think...

Trouble opening telnet session
3 direct replies — Read more / Contribute
by BrianDStark
on Mar 18, 2019 at 22:01
    I have a script that I run on a Windows 10 Box that opens a telnet session in a CentOS 7 Linux box. I am trying to run the script connecting to Linux Fedora 27 (running on same Windows box), I verified that telnet works using the Windows Telnet Client and logging into Fedora, but when I run my script it times out trying to open a telnet session. Is there a known issue with the Fedora Kernel 4.20 Telnet server? The identical script runs fine when connecting to CentOS 3.10. Hoping its something simple like the login prompt is different. Brian
Calling a C++ subroutine from Perl
4 direct replies — Read more / Contribute
by ibm1620
on Mar 18, 2019 at 20:36
    Dear Monks,

    Our company obtained a C++ source code license for Metaphone3 and I want to test it using Perl as a driver. I'm wondering what my options are. In the past, when I needed to call a complex C subroutine from Perl, I've written a standalone C++ program that accepted command-line parameters, called the subroutine, and wrote the output to STDOUT, and then "called" it using qx//. That's certainly still a possibility, but on the offchance that the forking and IPC would pose a performance hit (I'm going to test 100M's of strings), I wondered if XS was a practical possibility.

    I have never written an XS module, and it looks daunting, but I thought there might be some XS stub code out there that I could easily tweak so that a Perl program could call one subroutine, passing in one string and getting two strings back; end of story.

    Any thoughts on the subject? Other approaches?

    (Metaphone3 is also available in Perl, but unfortunately that's a separate license.)

Net::OpenSSH pass options to ssh
2 direct replies — Read more / Contribute
by zn553
on Mar 18, 2019 at 10:01
    Hello how do I pass several options to ssh using Net::OpenSSH module i have this:
    my $ssh = Net::OpenSSH->new($host, user => $user, master_opts => ['-vvv'], key_path= $private_key_path, default_ssh_opts=>[-o =>'Port=24'] ); $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error;
    I would like to do something similar to this: ssh -o ConnectTimeout=60 -oport=24 when I try it is still port 22 being used. thank you
Win32::OLE and Word: accessing all headers and comments
1 direct reply — Read more / Contribute
by mdamazon
on Mar 17, 2019 at 14:54

    Thanks for allowing me to seek your wisdom. I have Word documents with headers and footers in them. I am able to use Win32::OLE to search and replace text in the primary header, no problem. How do I make sure that I access all the headers in the document so that I am assured to replace text in all of them?

    Also, how do I access comments through Win32::OLE? I also want to search and replace in all the comments, if possible.

cpanm installation problems with mixed case files
2 direct replies — Read more / Contribute
by LanX
on Mar 16, 2019 at 18:59

    I'm having a (not very dramatic) installation problem with Emacs::PDE

    The author decided to host this project, which is basically a bunch of lisp modules plus some Perl helpers on CPAN.

    Now the installation fails on windows with a weird "permission denied" and no "proper Makefile.PL/Build.PL":

    >cpanm Emacs::PDE --> Working on Emacs::PDE Fetching +.tar.gz ... OK Could not open file 'C:\Users\ROLFLA~1\.cpanm\work\1552775378.16224\Em +acs-PDE-0.2.16\lisp\templates\TEMPLATE.makefile.tpl': Permission deni +ed at C:\Perl_524\site\bin/cpanm line 33. Could not extract 'Emacs-PDE-0.2.16/lisp/templates/TEMPLATE.makefile.t +pl' at C:\Perl_524\site\bin/cpanm line 33. Configuring Emacs-PDE-0.2.16 ... N/A ! The distribution doesn't have a proper Makefile.PL/Build.PL See C:\U +sers\ROLFLA~1\.cpanm\work\1552775378.16224\build.log for details.

    When looking into the work directory I notice that large parts of the tar.gz wasn't unpacked.

    I checked on linux-vm and all files where available there.

    BUT when looking into the directory Emacs-PDE-0.2.16\lisp\templates I noticed two identical files with differing capitalization:

  • TEMPLATE.makefile.tpl
  • TEMPLATE.Makefile.tpl *

    Obviously an OS problem, windows acts case insensitive while case matters on linux.

    But I'm a bit stunned.


    • why permission denied?
    • shouldn't the error message be more explicit?
    • if the extractions fils, why does cpanm still continue to try the installation?
    • is there a general policy regarding files and case in cpan-modules?
    • should there be one?
    • would it make sense if CPAN testers test for such ambiguities?
    Many questions, but I don't know which is the right address to inform about this kind problems.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

    *) NB: it's only a coincidence that they are called "makefile", nothing to do with the CPAN installer.


    FWIW this bug was already reported 5 years ago:

Install set of modules in new Perl
2 direct replies — Read more / Contribute
by Anonymous Monk
on Mar 15, 2019 at 18:10


    On macOS I use clone-modules command for perlbrew in order to reinstall a set of CPAN installed module in a new version of Perl. Now I need to work on Windows (Strawberry Perl, Portable, Berrybrew): is there any easy way to automate the installation of my set of CPAN module in the new Perl version? For now I am doing it manually... but as they are around 30 I guess a better method should be used...

Checking @INC for available modules without side-effects?
1 direct reply — Read more / Contribute
by LanX
on Mar 15, 2019 at 16:22

    Is it possible to check if a module is available for use in @INC, BUT without side effects?

    I mean eval { "require MODULE" } will at least compile and execute any BEGIN block inside at compile time.

    Background: I have a project where I allow to dynamically add freely named modules via INC-hooks*, it would be nice to know beforehand if there are potential conflicts with already available modules.


    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice


    of course apart of the obvious solution to parse the dirs and hooks in @INC by myself, like shown in require

    *) see require for explanation

Win32::OLE and Word docs "Marked as Final"
1 direct reply — Read more / Contribute
by mdamazon
on Mar 15, 2019 at 09:29
    I have a project where I am re-purposing some older Word docs. I copy the old documents to a new folder, open them, execute a search and replace using Win32::OLE, then save them. That works fine, except those documents that have been "Marked as Final", which I am unable to make changes to. Is there a way in Win32::OLE to 1.) check if the document is marked as final, and if so, 2.) unmark the document. Thanks!
Mysterious crash of perldoc
4 direct replies — Read more / Contribute
by Textorix
on Mar 14, 2019 at 15:09

    Brethren and sistren (if thatís a word),

    First post here. Seeking wisdom on the use of perldoc to look at new POD content that Iíve been trying to write, as for me itís exiting with error status.
    Has anyone had this happen and discovered a solution?

    Iíve inherited some Perl code that is fairly devoid of documentation and contains no POD at all. Being fairly new to Perl and new to this project, I figured hey why not try to start writing some POD, at least for the things that Iím changing significantly.

    The trouble is that, when I run perldoc -F or perldoc -t -F on my file, it doesnít produce any output, and exits with a status code of 1.
    This is happening to me on two machines, one with CentOS 6 and the other with Mac OS X Mojave. Perl versions are 5.10.1 and 5.18.2, respectively.

    I ran perl -cw and podchecker on my file and it was blessed by both commands, so my impression is that the problem is not with my file content. Also, Iím not running as root or using sudo.

    I tried setting PERLDOCDEBUG, up to as high as 100 (not sure if higher would accomplish anything), and the last thing reported in the debug output is that itís looking for my file. Then nothing.
    I have set PERLDOC_PAGER to less -+C -E; this didnít appear to change anything.

    The less and man commands work fine on both machines, and perldoc does OK on an installed module (e.g. perldoc CGI).

    At the suggestion of choroba in the chatterbox (thank you), I tried using strace on the command. In the strace output, I can see that my file is getting read (all contents) and closed. After the file is closed, this appears next:

    rt_sigaction(SIG_0, NULL, {0x9f0ed807, [], SA_RESTORER|SA_RESTART|SA_INTERRUPT|SA_NOCLDWAIT|0x2577268, (nil)}, 8) = -1 EINVAL (Invalid argument)

    Following that are 66 other rt_sigaction calls for other signals (SIGHUP, SIGINT, etc.) and those others all return 0 (success). Then exit_group(1), and thatís the end. The process exits with status 1.

    Iím guessing that the EINVAL return from that first rt_sigaction call may be because the system considers SIG_0 to be an invalid signal, and that this EINVAL return may be related somehow to perldocís decision to exit_group(1). But these are mere guesses.

    Does anyone have other suggestions or insights? This situation is rather disappointing, as not having perldoc working will significantly reduce the motivation to write any more POD.

    Hereís a super-simple example script (not the actual code I was documenting) for which perldoc -F is exhibiting the same problem.

    #!/usr/bin/perl -w use strict; =pod My documentation. =cut

    Thank you...


    The situation has been resolved (thank you to all for replies to this post). Quoting here from further down (Re^4) in the discussion with pryrt...

    There appear two have been two issues contributing to my situation. One was the lack of a heading starter, as you pointed out. That appears to be the cause of the status=1 error exit. The other is that, on both of my systems, I was seeing no output because of the PERLDOC_PAGER=ďless -+C -EĒ value that I was using. Because my POD text is so short... less than one page... the ď-EĒ option was causing less to exit immediately (normal exit) after displaying the text. So there still appeared to be no output -- although looking more closely, the screen sometimes flickers slightly while the output appears and then disappears. In this case the exit status was normal 0 instead of 1.


    That said, Iím a bit surprised that this heading element is required. In the perlpod web page, when I read ďYou can simply type in your text without any markup whatsoever, and with just a blank line before and after,Ē apparently I took that too literally, or perhaps out of context. Looking at the page again, it still doesnít look obvious to me that a heading paragraph is required to be present, from the description in that page. Itís also a bit odd that the podchecker indicated all was OK in my original file, despite lack of that element whose absence caused an error in perldoc.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2019-03-20 06:55 GMT
Find Nodes?
    Voting Booth?
    How do you Carpe diem?

    Results (97 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!