Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

The Monastery Gates

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

Donations gladly accepted

If you're new here please read PerlMonks FAQ
and Create a new user.

New Questions
What basic things should I know about versioning modules?
3 direct replies — Read more / Contribute
by nysus
on Feb 23, 2017 at 06:34

    I'd like to get some general guidance on how to properly use versioning for my modules.

    My question is prompted by the Module::Starter::PBP module. It has a starter template here.

    The starter template throws an error on this line: use version; $VERSION = qv('0.0.3');. The error is Global symbol "$VERSION" requires explicit package name (did you forget to declare "my $VERSION"?)

    While I could slap a my in front of it and be on my way, I am wondering if maybe it was purposefully left off. I also don't know how this line might be used by other modules. And should I use "my" or "our?" What does qv do? I can't find it in the perldoc but I do find mention of it here on CPAN. But I never installed that module to my knowledge.

    If someone could point me to a good resource that can help explain the what's, why's, and how's of module versioning, I'd appreciate it. Thanks.

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

Perl modules that I can use for Multithreading
6 direct replies — Read more / Contribute
by elpis
on Feb 22, 2017 at 08:12

    I want to parallelize a code written in Perl. The code loops through multiple files and calls a subroutine for each file. I also need to share some readonly local data-structures with the subroutine.

    sub process_in_parallel { my $readOnlySchema = foo(); foreach my $file (@files) { validate_the_file($file,$readOnlySchema); } }

    I am pretty new to perl programming and hence need a lot of advice here. What are the perl modules that the perl monks can recommend for this scenario?

    I tried some of the following:

    - threads : The problem with this is managing the threads. Is there an efficient thread Manager or thread pool library that can help me with this? I am also not sure if I can share the readOnly object easily.

    -Parallel::ForkManager : The problem with this is that it forks processes rather than threads and is increasing the time of execution in my case.

    Can you please suggest other libraries also?

    I have the same question posted here also :
Perl5 Perl6 forking
6 direct replies — Read more / Contribute
by reverendmred
on Feb 21, 2017 at 21:22
    I'm returning to Perl after an absence of a couple years to pick up a lot of code I left in beta. Now, Perl6 has changed all the rules.

    Languages need to evolve, but when C evolved into different varieties, ultimately, it was called a different language. The same seems to be true of Perl.

    Is there any way to ensure a switch in Perl 6 so you can choose between languages? Once long ago, we used the top of the file to point the script at the executable. Can we have Perl6 provide something like this to preserve legacy code. It would also be nice for CPAN modules to provide a fork so we can keep alive old stable code.

    I know you must now be thinking 'oh my god, you can't have two languages in one application' but actually, you can. When last left Perl behind and returned to it in the early 00s, it had switched from a procedural scripting language to a very fake OO language. I say very fake, because I worked on a bioinformatics project coming from a pure 00 environment and in my nw position I got criticized for crappy perl code and not doing good OO -- which only showed me my colleagues knew nothing about Perls history and had absolutely no idea what OO really was.

    The point is, if you had good OO like Perl5 code, there should be no problem running it alongside new Perl6 code as long as you treat them as separate languages and you have a fork of the legacy CPAN code. What you need to make sure is that the interfaces between your Perl5 and Perl6 code are stable and work. (Of course, I hate to say, but that old bioinformatics project was not good OO and violated every aspect of encapsulation).

    So, is there a way we can fork projects and modules on CPAN? This would be really, really useful.


cgi progressbar
2 direct replies — Read more / Contribute
by bigup401
on Feb 21, 2017 at 07:03

    i have tried to look around the proper way of progressbar in html. bt no good information i have been playing around with progrssbar in commandline bt not in cgi. as they say perl is good for open source bt web apps not easy too much time to take and alot tests

    any idea or simple. i appreciate

    if (execute code){ # execute code to run } while (the code is runing ) { # show the progress .. show the progressbar from 1 } elsif (the code has finished running) { #stop the progressbar at 100% } else (the code has not executed) { # dont let the progressbar to run } print "Content-type: text/html\n\n"; print <<START_HTML; <!DOCTYPE html> <html> <style> #myProgress { width: 100%; background-color: #ddd; } #myBar { width: 1%; height: 30px; background-color: #4CAF50; } </style> <body> <h1>JavaScript Progress Bar</h1> <div id="myProgress"> <div id="myBar"></div> </div> <br> <button onclick="move()">Click Me</button> <script> function move() { var elem = document.getElementById("myBar"); var width = 1; var id = setInterval(frame, 10); function frame() { if (width >= 100) { clearInterval(id); } else { width++; = width + '%'; } } } </script> </body> </html> START_HTML
Solved : decimal to hex in an array
3 direct replies — Read more / Contribute
by t-rex
on Feb 21, 2017 at 05:31

    hello monks,

    I have an array where I need to convert every even index element to hex , I have written a code but the output is not what i expected

    my @a = "1 10 5 345 2 12"; my $indx=1; foreach my $ind (@a) { print "IND = $ind and index = $indx\n"; if ($ind%2==0) { $ind = sprintf("0x%x",$ind); } $indx++; } print "final conversion input array = @a\n";

    actual output : 1 0xa 5 345 0x2 0xc

    expected output : 1 0xa 5 159 2 0xc

    please let me know where I am going wrong ?

    edit : i got my error , just because of same names i made a silly mistake and couldn't see , sorry for the trouble guys

http post
2 direct replies — Read more / Contribute
by bigup401
on Feb 19, 2017 at 09:18

    i got some issue when i execute my code i get this Response Code: 411

    #!/usr/bin/perl use strict; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $ua = new LWP::UserAgent; my $senderid = "demo"; my $num = "447777777777"; my $sms = "demo"; my $rep = HTTP::Request->new(POST => " +s/send/?apiKey=edftr44456&message=$sms%20HTTP%20API&from=$senderid&to +=$num"); $rep->content_type("application/x-www-form-urlencoded"); $rep->content_type("Content-Type' => 'application/json"); my $repobj = $ua->request($rep); my $repcode = $repobj->code; print 'Response code: ' . $repcode . "\n";
Perl 6 OOP: before and after methods "CLOS style"
7 direct replies — Read more / Contribute
by Anonymous Monk
on Feb 18, 2017 at 18:37

    I'm learning Perl 6 and I'm constantly blown away by amazing Perl 6 features, it's something I experienced only while I was learning a bit of Common Lisp.

    I wish to know if in the Perl 6 MOP there is something similar to CLOS before/around/after methods.

    Also, given that my experience with programming is mainly quick procedural scripts (and, sadly, one big system in classic asp and vb for work) , which books/resources can give me a good grasp of Perl 6 OOP philosophy? For CL I loved the CLOS book by Kleene, but Perl 6 approach seems different (Smalltalk-ish???).

    Thank you very much for your wisdom.

How to detect non printable characters and non white space characters? [RESOLVED]
3 direct replies — Read more / Contribute
by thanos1983
on Feb 17, 2017 at 04:49

    Hello again Monks,

    Lately I have been bombing the forum with questions but no matter how much I experiment with my code I can not figure out the solution(s) to my problems this is why I keep asking questions over and over.

    To the question, I have a hash of hashes with hundreds values on each hash. I want to use a negative condition on both detecting white space character or non printable character. In such a case I want to delete the element from the hash (if does not contain white space character or non printable character).

    I tried the conditions separately and they work just fine, at least based on my experimentation examples. I need to combine them in a nested if because a value with no spaces it does not mean that it does not contain special characters.

    Based on my research in order to detect non printable characters you can use either this /[^[:print:]]/g or this /[^[:ascii:]]/ regex expression found here (Finding out non ASCII Characters in the text)

    Sample of code:

    #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my $str = 'a[bdy]dfjaPÑsdafÜ'; my $str_2 = 'WAP'; my $hoh_ref = { hash_1 => { a => 'a[bdy]dfjaPÑsdafÜ', b => 'WAP' }, hash_2 => { c => 'Te st' } }; print Dumper $hoh_ref; foreach my $key (sort keys %{$hoh_ref}) { foreach my $value (keys %{$$hoh_ref{$key}}) { # If not white space character or non printable character remove e +lement if ($$hoh_ref{$key}{$value} !~ /[^[:print:]]/g || $$hoh_ref{$key}{$value} !~ /\s/) { delete $$hoh_ref{$key}{$value}; } elsif ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { while ($$hoh_ref{$key}{$value} =~ /[^[:print:]]/g) { print "Non Printable Characater:\t$&\n"; } } } } print Dumper $hoh_ref; __END__ $VAR1 = { 'hash_2' => { 'c' => 'Te st' }, 'hash_1' => { 'b' => 'WAP', 'a' => 'a[bdy]dfjaPÑsdafÜ' } }; $VAR1 = { 'hash_2' => {}, 'hash_1' => {} };

    Desired output would be:

    $VAR1 = { 'hash_2' => { 'c' => 'Te st' }, 'hash_1' => { 'a' => 'a[bdy]dfjaPÑsdafÜ' } };

    Thanks in advance for your time and effort.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Critical sections; In the Perl interpreter
4 direct replies — Read more / Contribute
by Wiggins
on Feb 16, 2017 at 13:45
    My interest is in critical sections in the Perl interpreter itself.
    I was asked by a friend, why after starting 150 web spider threads, his system would bog down until it seem to stop, but was still running?

    I proposed that each of those threads was a separate process, with each having a full Perl interpreter. But they were all sharing the same .so libraries, and the number of critical sections(CS) that the interpreter had to go through would create single file bottle-neck after bottle-neck.

    Are there CS in the interpreter? Are there certain functional areas that have significantly more CS than others

    It is always better to have seen your target for yourself, rather than depend upon someone else's description.

Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-02-23 12:48 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (346 votes). Check out past polls.