Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Seekers of Perl Wisdom

( #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. Post a new question!

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.

User Questions
cpan enigma
2 direct replies — Read more / Contribute
by BernieC
on Jan 10, 2020 at 11:17
    What does this mean?
    cpan> install Par::Packer Warning: Cannot install Par::Packer, don't know what it is. Try the command i /Par::Packer/ to find objects with matching identifiers. cpan> i /Par::Packer/ Fetching with LWP: http://cpan.strawberryperl.com/authors/id/R/RS/RSCHUPP/CHECKSUMS Module id = PAR::Packer CPAN_USERID RSCHUPP (Roderich Schupp <rschupp@cpan.org>) CPAN_VERSION 1.049 CPAN_FILE R/RS/RSCHUPP/PAR-Packer-1.049.tar.gz UPLOAD_DATE 2019-05-31 INST_FILE (not installed)
    It *looks* like it found it, but it says it doesn't know what that is. What do I do to help it "know" about that module.
Shipping MANIFEST.SKIP
2 direct replies — Read more / Contribute
by hippo
on Jan 10, 2020 at 07:31

    I have recently noticed that there is a considerable number of dists which ship with MANIFEST.SKIP and so started to wonder why that might be.

    The only use I can see for MANIFEST.SKIP is to rebuild MANIFEST and the only reason for that is to rebuild the dist for further distribution. That implies the dist having been altered in some way, otherwise the rebuild would be unnecessary.

    If the dist has an open repository then I would expect anyone altering it to use that as their source (and MANIFEST.SKIP should happily live there). Contrarily if there's no public source then all a contributor has to work with is the shipped code. But in this case there are no other non-standard files to be avoided packaging, so again MANIFEST.SKIP is unnecessary.

    Either I am missing something or there's no need to ship MANIFEST.SKIP at all. Probably it's the former. Do let me know.

TimeDate 2.30 - Bug in test-code
2 direct replies — Read more / Contribute
by Skeeve
on Jan 10, 2020 at 04:20

    Yesterday I stumbled across a bug in https://metacpan.org/release/TimeDate.

    One of the modules I install in a docker image is depending on this module but it failed to install.

    Reason given was

    Redundant argument in printf at t/date.t line 180.

    Looking at that line printf "%-40s\t%s\n", $_,$x,"\n"; it's clear that the ,"\n" is the redundant part.

    Besides mailing the author (who didn't provide any contribution information), what could one do to fix this issue?

    For the time being I force-install the module. Better would be, I guess, to apply a diff.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Date::Manip ParseRecur help needed
3 direct replies — Read more / Contribute
by cormanaz
on Jan 09, 2020 at 14:32
    I am trying to get Date::Manip to list the date of each Friday in the first 5 months of this year. I have tried @date = ParseRecur('2020:1-5:0:5:0:0:0'); and @date = ParseRecur('every friday of every week in 2020'); and both return empty lists. What am I doing wrong?
Perl to generate PDF
6 direct replies — Read more / Contribute
by BernieC
on Jan 09, 2020 at 11:11
    I've done a search and there are a LOT of threads having to do with PDF generation, and metacpan reveals there are hundres of PDF-related modules. It is all very mindboggling, especially for someone {like me} that doesn't really understand the format of a PDF file. What I'd like to do is produce a "pretty" document. I don't care much what sort of output I produce, since almost anything can be changed into something else.

    I've contemplated trying generating HTML {and there's even and HTML->PDF module :o)}, I've considered generating "rich text". It is all a bit confusing.

    Any recommendations on a good place to start to try to get a handle on not too complicated to use fancy-document creation? I don't anticipate needing anything much more complicated than that I could do in HTML, and I've done that before {in CGI programs} but I was wondering if there was something with similar {or better?} capabilities. Thanks!!

Too Many IDs
3 direct replies — Read more / Contribute
by The_Dj
on Jan 09, 2020 at 01:39

    Hi, Monks.

    For reasons probably best described as DBI, I have data like this:

    %dat_by_id = ( 1=>{ id=>1, sn=>'a', more=>'foo' }, 2=>{ id=>2, sn=>'b', more=>'bar' } );

    You get the idea.

    Now, for reasons best described as argh! I also do:

    %dat_by_sn=(map { $_->{sn} => $_ } values %dat_by_id);

    Sadly I do need to reference entries be either field throughout the rest of the code.

    Is there a better way? (My dataset runs to a few million records. Big but not too big.)

    I don't (currently) need a 3rd,4th,...nth field, but it's only a matter of tiem untill someone adds a UID field, or something else to compicate my life

Error with Dancer2::Plugin::Auth::ActiveDirectory
1 direct reply — Read more / Contribute
by TieUpYourCamel
on Jan 08, 2020 at 16:14
    I am attempting to use Dancer2::Plugin::Auth::ActiveDirectory and am receiving an error I can't figure out. Here is my code: (with unrelated routes removed)
    package myApp; use Dancer2; use Dancer2::Plugin::Auth::ActiveDirectory; get '/loginForm' => sub { template 'loginForm' => { 'title' => 'loginForm' }; }; post '/loginPost' => sub { session 'user' => authenticate(params->{user}, params->{pass}) +; return template 'loggedIn' => {}; }; true;
    And these are my settings in config.yml:
    plugins: Auth::ActiveDirectory: host: xxx.xxx.xxx.xxx principal: 'OU=USER,OU=ACCOUNTS,OU=OUROU,DC=our,DC=domain,DC=com' domain: our.domain.com rights: definedright1: 'Our Users'
    The error message is:
    Can't call method "groups" on unblessed reference at /home/camel/perl5 +/perlbrew/perls/perl-5.30.1/lib/site_perl/5.30.1/Dancer2/Plugin/Auth/ +ActiveDirectory.pm line 140. /home/camel/perl5/perlbrew/perls/perl-5.30.1/lib/site_perl/5.30.1/Danc +er2/Plugin/Auth/ActiveDirectory.pm around line 140 135 136 register authenticate => sub { 137 my ( $dsl, $name, $pass ) = @_; 138 my $user = _connect_to_ad($dsl)->authenticate( $name, $pass + ); 139 return $user if $user->{error}; 140 my $user_groups = [ map { $_->name } @{ $user->groups } ]; 141 return { 142 uid => $user->uid, 143 firstname => $user->firstname, 144 surname => $user->surname, 145 mail => $user->mail,
    I've tried two different AD accounts, both of which are members of the "Our Users" group, and get the same error message. If I put in an invalid password I get a different error. As far as I can tell I am following all of the directions in the documentation, and I'm using the same AD settings that are currently working in the PHP webapp that I'm attempting to rewrite in Perl. Any insights will be greatly appreciated.
Failure to install PDL::Graphics::Simple on Windows 10
5 direct replies — Read more / Contribute
by zubenel0
on Jan 08, 2020 at 15:44

    Dear Perl Monks,

    I wanted to run an example from PDL Book http://pdl.perl.org/?page=FirstSteps and for that I needed PDL::Graphics::Simple module. I used Strawberry Perl PDL edition v.5.30.1 on Windows 10 and tried to install this module with cpanm PDL::Graphics::Simple function but encountered an error. The last lines of log file show that several tests failed:
    Test Summary Report ------------------- t/simple.t (Wstat: 1536 Tests: 85 Failed: 6) Failed tests: 5, 73-74, 78, 80, 82 Non-zero exit status: 6 Files=1, Tests=85, 2 wallclock secs ( 0.05 usr + 0.00 sys = 0.05 CPU) Result: FAIL Failed 1/1 test programs. 6/85 subtests failed. gmake: *** [Makefile:871: test_dynamic] Error 6 -> FAIL Installing PDL::Graphics::Simple failed.
    I found that there were more people having problems with this module and CPAN Testers matrix shows many failures. Thanks for any help on how to solve this in order to run examples from PDL book.
Best Perl REPL/Shell on Win (and Linux)?
4 direct replies — Read more / Contribute
by LanX
on Jan 08, 2020 at 11:43
    Hi

    I'm very used to tweak the perl-debugger for my needs to get a shell experience.

    Under Win it's not that easy anymore because of the lack of CTRL shortcuts.

    I can get used to the fact that CMD translates CTRL-a to select-all instead of beginning-of-line ...

    ... but CTRL-r for reverse searching the history is a life saver!

    DB<1> (reverse-i-search)`':

    Now I tried calling the debugger under Git-Bash, which has a decent xterm emulation under bash. Unless when I call perl -de0 this is lost.

    I also tried to install Term::ReadLine::Perl and Term::ReadLine::Zoid and did set %PERL_RL% accordingly.

    I also tried installing Devel::REPL (incl. dependencies) and Reply but no luck with reverse search.

    My best bet ATM is to run the debugger under emacs.

    so ... what do you use and does it work the same under Win and Linux?

    My requirements:

    • Command Up/Down with arrow keys
    • Interactive reverse search in history
    • REPL
    • Persistent Command-History
    • Shell out commands
    • Aliases
    • Configuration via .rc file
    Nice-to-Have
    • tab-completion
    • multi-line detection
    • option for persistent lexical vars
    • color-support
    This seems to be all available for Linux, but poorly tested resp. hard to achieve under Win.

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

    ) !!dir in the debugger returns escape codes which "destroy" the terminal

date and time difference
3 direct replies — Read more / Contribute
by invisiblehand
on Jan 08, 2020 at 08:50

    (perl version 5.8.7)

    I have two date strings and and try to calculate date and time difference between two dates and times.

    But the difference looks incorrect, could you help me to get the correct value?

    notBefore=Nov 23 22:31:12 2019 GMT

    notAfter=Mar 19 06:52:23 2020 GMT

    #!/usr/bin/perl use Time::Local; # FILE READ IN $log_file = './raw.txt'; open(FH, '<', $log_file) or die $!; while (<FH>) { if(m/START/) {chomp; $sdname = $_;} if(m/notBefore/) { chomp; ($notB1, $notB2) = split('=', $_); $notB2 =~ tr/:/ /; my($mon,$mday,$hour,$minute,$sec,$year)=split(/ /,$notB2); #print $mon, $mday, $hour, $minute, $sec, $year; $time_1 = timelocal($sec,$minute,$hour,$mday,$mon,$year); } if(m/notAfter/) { chomp; ($notA1, $notA2) = split('=', $_); $notA2 =~ tr/:/ /; my($mon,$mday,$hour,$minute,$sec,$year)=split(/ /,$notA2); $time_2 = timelocal($sec,$minute,$hour,$mday,$mon,$year); } if(m/END/) {printf("%s %s %s\n", $sdname, $notB2, $notA2); print $time_2,"\n",$time_1, "\n"; $diff_time = $time_2 - $time_1; $diff_time1 = ($diff_time/86400); print "diff_time :$diff_time:$diff_time1:\n"; } }

    ===output=====

    SD0101START Nov 23 22 31 12 2019 GMT Mar 19 06 52 23 2020 GMT

    1579384343

    1548250272

    diff_time :31134071:360.348043981481:

    ========rax.txt===========

    SD0101START

    notBefore=Nov 23 22:31:12 2019 GMT

    notAfter=Mar 19 06:52:23 2020 GMT

    SD0101END

    SD0201START

    notBefore=Nov 24 11:11:11 2019 GMT

    notAfter=Mar 19 06:52:23 2020 GMT

    SD0201END


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, 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, 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
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2020-02-28 03:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?










      Results (122 votes). Check out past polls.

      Notices?