Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses


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

If you've discovered something amazing about Perl that you just need to share with everyone, this is the right place.

This section is also used for non-question discussions about Perl, and for any discussions that are not specifically programming related. For example, if you want to share or discuss opinions on hacker culture, the job market, or Perl 6 development, this is the place. (Note, however, that discussions about the PerlMonks web site belong in PerlMonks Discussion.)

Meditations is sometimes used as a sounding-board — a place to post initial drafts of perl tutorials, code modules, book reviews, articles, quizzes, etc. — so that the author can benefit from the collective insight of the monks before publishing the finished item to its proper place (be it Tutorials, Cool Uses for Perl, Reviews, or whatever). If you do this, it is generally considered appropriate to prefix your node title with "RFC:" (for "request for comments").

User Meditations
Perl as interactive Shell?
7 direct replies — Read more / Contribute
by LanX
on May 12, 2017 at 10:51

    what are the fundamental obstacles hindering Perl to be used instead of Bash and or PowerShell?

    For instance I'm aware of easy piping with | and redirection >

    but this could be handled by reversing the direction and aliasing some builtin commands to Perl subs

    for instance ls | grep '.txt'|less could easily be less grep {/.txt/} ls

    with less and ls implemented as subs (see also Shell )

    What else?


    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    °) see also Shell and aliases in perldebug like | for paging

RFC: Test::Contract - extensible object-oriented runtime check series
1 direct reply — Read more / Contribute
by Dallaylaen
on May 07, 2017 at 10:17

    Hello dear esteemed monks,

    More than once I felt an urge to insert a set of Test::More's checks into my application code, for instance when loading a plug-in or validating a complex piece of data. However, Test::More/Test::Builder is best suited to only run inside test scripts.

    So I came up with a module to fill the gap. And I'm going to release it to CPAN soon, unless some huge problem is detected.

    The idea is as follows:

    • A contract is an object representing a series of checks/assertions. It has some control methods as well as the checks themselves. A counterpart method exists for every of Test::More's checks.
    • The most basic check is refute($condition, $message) which may be viewed as an inverted ok(). It is assumed that a passing test does not need attention, while a failing one begs for an explanation.
    • New checks may be added quite easily, appearing as both contract's methods and individual functions that run just fine under Test::More.
    • And these checks can be tested (who shaves the barber?) fairly easily using the contract_is ($contract, "11000101") assertion.
    • Prototyped exception-proof contract { BLOCK; } sugar exists to reduce the bolierplate. Such blocks may be nested.

    What usage I can see this far:

    • loading user-supplied code;
    • validating complex pieces of data;
    • checking that multiple implementations (XS vs PP, different backends etc) behave exactly the same;
    • maybe some use exists for development using traits/mixins (aka Moose::Role);
    • maybe some assertion modules may be armed with a refute($what_went_wrong, $why_we_care) call.

    Some details (this is basically a copy-and-paste of the project's README):


    As stated above, this module is going to be released to CPAN, but maybe I'm missing something very obvious here...

    My previous submission on the topic: RFC: Test::Refute - extensible unified assertion & testing tool.

    The project link again:

    Thank you, and hope you enjoyed the reading!

Confession of a hard headed Monk
2 direct replies — Read more / Contribute
by Lady_Aleena
on May 05, 2017 at 23:43

    Over the last few days, I've been doing a project that is forcing me take a new harder look at everything I've written: code and markup. One of the items which came up in my audit was a little subroutine which takes a number (usually scalar(@list)) and returns how many columns the list would be in according to exponential calculations. The default behavior of this subroutine is to return a word number not an integer. When I looked at it again, a voice in the back of my head told me the subroutine should return the integer by default because integers are more useful. I also had the sinking feeling someone here probably pointed that out to me, and I ignored it. I wanted what I wanted, and no one was going to make me change my mind at the time. I had to change my own mind and pay the price for it later.

    So, this is my confession. I am a doofus. I am hard headed and obstinate when it comes to attaining my short term goals. I crawled into my shell to avoid any good advice about coding for the future.

    So here is my old sub...

    use Lingua::EN::Inflect qw(NUMWORDS); sub get_columns { my ($max_cols, $amount, $number) = @_; if ($amount <= $max_cols ** 2) { for my $num (1..$max_cols) { if ($amount >= $num ** 2 && $amount < ($num + 1) ** 2) { return $number && $number =~ /^[yt1]/ ? $num : NUMWORDS($num); } } } else { return $number && $number =~ /^[yt1]/ ? $max_cols : NUMWORDS($max_ +cols); } }

    And the new more useful sub...

    use Lingua::EN::Inflect qw(NUMWORDS); sub get_columns { my ($max_cols, $amount, $word) = @_; if ($amount <= $max_cols ** 2) { for my $num (1..$max_cols) { if ($amount >= $num ** 2 && $amount < ($num + 1) ** 2) { return $word && $word =~ /^[yt1]/ ? NUMWORDS($num) : $num; ############################################# Delete to + get rid of Lingua::EN::Inflect } } } else { return $word && $word =~ /^[yt1]/ ? $NUMWORDS($max_cols) : $max_co +ls; ################################################### Delete +to get rid of Lingua::EN::Inflect } }

    I feel bad for only now realizing returning a integer by default would be more useful than returning a number word. I think I spoke aloud when I called myself a doofus for returning a number word by default.

    I've been doing a lot of rethinks lately. Some of my "utility" scripts seem useless in a broader sense.

    The great advice I got from Monks long ago is finally settling into my head. I hope I am better with future advice, but that is to be seen.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Assigning to Hash Values (updated)
No replies — Read more | Post response
by haukex
on Apr 28, 2017 at 12:49

    The thread "Randomly reassign hash keys" got me thinking about this one. The values doc says:

    Note that the values are not copied, which means modifying them will modify the contents of the hash.

    This means that $_++ for values %hash; will modify the original hash values, and the following (based on this AM post) will assign to the values of the hash:

    sub { @_[0..$#_] = qw/r s t/ }->(values %hash);

    The above work because both the foreach loop variable and the elements of @_ are aliases to the original scalars. The slice in the second example is necessary, since @_ = ... would clobber the array and remove the aliasing, instead of assigning to its elements.

    However, values itself is not lvalue, meaning that values(%hash) = qw/a b c/; won't work. Neither will (values(%hash))[0] = 'a';.

    Here's my "invention", which I present as a curiosity rather than a suggested solution. It makes use of Lvalue subroutines and Prototypes. The parens on the left are necessary for the sub to be called in list context.

    sub lvalues (\%) : lvalue { values %{$_[0]} } (lvalues %hash) = qw/i j k/; # works!

    Since the order of the values returned by values is random, this probably isn't particularly useful other than in the context of the thread I mentioned above:

    (lvalues %hash) = shuffle values %hash;

    Updates 1&2: However, note that repeated calls to (lvalues %hash) = values %hash; will only "randomize" the values once, and on older Perls the order won't be very "random" at all apparently not randomize at all, I would guess because the order of the returned values is not randomized between the calls to values. Some interesting reading on the topic: Re^2: setting PERL_PERTURB_KEYS & PERL_HASH_SEED in a perl file and Re^2: Curious: are anon-hashes in random order?

    Minor updates for clarification.

Big thank you to the Perl community.
3 direct replies — Read more / Contribute
by Anonymous Monk
on Apr 24, 2017 at 06:21

    Revered Monks and dwellers of this venerated place,

    I've been here for approximately two months now and I have no words to express my gratitude. The level of information shared here is amazing. The knowledge of the monks just blows my mind. Answers given here are of very high quality and I've come to realize that PerlMonks is the best place to learn Perl

    Just wanted to take a moment to extend a heartfelt "Thank You" to all you knowledgeable and helpful folks here. Spending a few minutes here is far more enriching and fulfilling. The suggestions and advice given by you Monks has literally shaved off hours of time. I started with Perl due to its practicality and immediacy with which it naturally lends itself to real life problem solving, but now, I have started falling in love with this amazing language, all thanks to you folks.

    This language deserves so much more attention and respect than it gets. All this talk of "Perl is Dead" now simply makes me wonder what the hell is going wrong with folks. This language will never die, because 1) its a pragmatic, practical and amazing language and 2)PerlMonks.

parallel programming and MCE - hubris and the frame
2 direct replies — Read more / Contribute
by Discipulus
on Apr 10, 2017 at 07:00


    Discipulus will never be a master: he likes too many things to become a master in one of them. He likes Perl. Here at the monastery he looks at tchnologies shown by monks, often like Linus watching russian names reading Dostoyevsky..

    He looks at Perl parallel programming with a big interest: he suspects parallel programming will be one of major battlefield for next generations of programmers. He'd like these programmer to be Perl ones.

    He has his cell carpeted of good examples of parallel programming. He also knows it is important to choose right masters to learn and follows with a big attention all parallel programming examples by, among others, BrowserUk and zentara.

    Then it happened that marioroy joined the monastery: his work, MCE - Many-Core Engine for Perl hit Discipulus's curiosity strongly: perhaps with such tool even he can, simply and safely produce some decent parrallel Perl program? Infact he's a bit lazy and many working examples are difficult to adapt without falling into horrible pitfalls.

    So Discipulus, taken his curage in his hands, has gone knocking at BrowserUk's and zentara's doors to ask their opinion...

    (please note that I confuse parallel programming terminology, still. So when I say multithread you can read parallel: the dialogue is interesting beside my grossolane errors.

    The Dialogue

    Discipulus:I follow your posts about parallel multithreading programming since ever and I follow them as a pupil (discipulus in latin..) follow his masters. I say this withut any flattery intention. As you stated somewhere (iirc) multithreading in Perl is difficult to realize but is possible to do as you shown many many times.
    What i will be glad to hear from you is an opinion about Perl MCE by marioroy available at and visible in many posts by marioroy here in the monastery.

    BrowserUk: I mostly don't recommend MCE, (though I have suggested people consider it a few times), simply because I don't us it personally.

    zentara: I havn't the time to test MCE out. Besides I would rather do it manually, since I have total control of the code, as in Reusable threads demo.

    Discipulus:Now I know you do not need such a thing like MCE to produce good multithread perl programs. but what about us? If i have the need or the curiousity to start write a threaded application i will follow your footsteps: i go to library, i search one of miles of your working complete examples, the closest to my need and i will expand it as my needs. But MCE seems a safe a clean alternative to have a multithread program without writing it from scratch.

    zentara:Another thing, Don't confuse forks and threads. MCE is based on forks, from what I can gather, not threads. It gets more confusing because on MS Windows, all processes are threads, not forks.

    BrowserUk:I don't use it personally be a) for the most part I don't need it; b) I have a very strong aversion to frameworks. But please note, I saying that I do not generally actively recommend MCE to people, I am not saying that I recommend against it.

    Discipulus:MCE is an alternative if you accept the overhead of using a framework: but this is very common in programming: was possible to write webpages without CGI some years ago, writing a server too but CGI was a cheap overhead in front of many pitfalls possible doing all by hand. The same for DBI..
    Is MCE something valuable in such perpsective? Is MCE a safer way to do parallel programming in perl, if you accept the minimal overhed and his learning curve?
    Fast is fast, i rerun many bechmarks proposed at PM by marioroy and i can confirm. But is solid rock? this is behaind my capabilities to tell. It introduce other pitfalls?
    I suspect MCE was highly undervaluated by the perl community and i think multithread is a key field for programmers of next generations: i'd like to see perl kicking competitors in the future.

    BrowserUk:If you have an application for multi-tasking that MCE has a widget for, and especially if you can attract the attentions of MarioRoy to construct and refine some examples for your purpose (and perhaps tweak it internally to address any shortcomings your application throws up) then you could do a lot worse. From a cursory inspection, the code seems well designed, constructed and documented, and the author seems to have the time and energy to support you.
    Beyond that I really don't have a lot to add.

    zentara:As far as the threads controversy goes, these are my thoughts.

    0. Threads tend to blow up unexpectedly, so don't use them for anything where you demand certainty and stability. Also many modules are not thread-safe,i.e. Tk

    1. Only use threads if you need to share data in realtime between threads in an easy manner, with threads::shared. Otherwise forking a new process is more efficient because you do not have to copy the parent thread's code into the spawned thread, and the process totally frees it's memory when finished.

    2. If you are going to use workers, the MCE module looks alright, although it reminds me of Parallel Fork Manager. If I was to chose the one foolproof way of doing the task of many workers sharing data in realtime, I would use Parallel::Fork::Manager along with SYSV Shared Memory segments. (zentara unfold a perchment with a wonderful example.. )

    Discipulus: the answer you gave me was somehow expected and somehow unwanted: I know you have no need for such framework because you can write down the right way a multithread perl program using perl and it's basic tools.
    But i've learn to not ask questions if i'm not prepared to receive back every answer :=)
    I also understand your avversion to frameworks in general: why be constrained into a frame when my puissance can spread out free and untouched? this is a declination of the hubrys in it's positive, perlish sense.
    But hubrys without solid rock foundations is foolishness and is where frameworks are valid options: I pay some of my freedom to the frame but i'm almost sure i'm not shooting on my own feets.
    In this perspective i consider MCE a true gem: can MCE open the way to multithread Perl programming to many,many more peoples? I think this is it's virtue and this merit i suspect was underestimated.
    I suspect and hope MCE can help perl programmers to afford such complex thing as multithread programming is.
    If so we must spend some energy to push MCE forward and suggesting it as a way to start, safely, to do multithreaded perl programs.

    (saying the above I not mean MCE is the only way to do it right with Perl parallel programming. As always TIMTOWTDT and any author can choose among many.)

    Note that I've ask both monks the permission to reproduce parts of our mails: if i've put something in wrong order, if something sounds not to be the real opinion of such monks it is my complete fault and i'll correct


    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.
How to lay out POD documentation for multi-faceted apps
1 direct reply — Read more / Contribute
by stevieb
on Apr 02, 2017 at 18:31

    Take Test::BrewBuild for instance.

    There are three included binaries (well, scripts) that accompany the various modules that make up the distribution, but it may not be clear to a user which one to read first.

    When you search CPAN for the distribution, it automatically loads the POD file for the main API module, in which I redirect users to read another doc if they are not looking to use the API directly.

    What type of approaches do I have here. Should I hijack the main module's POD with the main binary's POD, and redirect to the other ones from there?

    What have others done in these situations, and as an end-user, what would you like to be presented with on a first glance after clicking on a search result?

    update: note that the first entry in the Changes file in the link above has been rectified, as I updated berrybrew late last week. Updating berrybrew rids one of the win10 issue. /update

My Perl-ish Neo-Gavinist Manifesto
3 direct replies — Read more / Contribute
by InfiniteSilence
on Apr 01, 2017 at 16:04

    A few people sent me messages via the Message Inbox that I could see under the 'Chatterbox' heading. More than once I admit to not using this messaging feature (even when I saw messages in there for me) because I sort of hate looking at that screen.

    Clicking on it shows what I can best describe as one of the most confounding utilities on this or any other website I frequent. And it is the reason for this meditation.

    When I normally look upon it I am immediately confronted with what appear to be checkboxes selected for me. This is not helpful. It says, 'Showing messages ' and then appears a 'From' and a 'To' checkbox immediately following. It is not obvious if I am supposed to select something else and under what circumstances I would have to do so (this feels particularly pressing when there are no messages for some reason). When I experiment and click on the 'From' checkbox it does not automatically de-select the 'To' one. After some thinking about it I realize that it would show both messages from and to me. It would have been far easier to have something that allowed me to see 'All Messages' even if offering such an option would be redundant.

    The next line has yet another checkbox next to 'not' in parenthesis with yet more options: Inbox, Archive, Deleted, all with parenthesis but some with what appear to be counts. There is yet another line that reads, 'constrain by content' which is apparently some way of saying, 'filter by,' followed by the ability to additionally filter by a user box which is not even a drop down list of user identities (minimally it could contain the users who have sent me something). This text is all in the English language which means it is to be read from left to right. When my eyes dart to the beginning of a line I should never have to guess what is going to be on that line. Think about it -- when reading a book every line you read tells you, using context clues, what you are about to read next. Webpages are no different.

    Now, I know what a few of you are thinking. The Perlmonks site doesn't use JavaScript. But that is not what I am saying. What I am saying is that this form could be improved without JavaScript. It mashes things together and makes no attempt to differentiate; it presents the user with form boxes pre-filled in; the word 'constrain' is used when filter would be more clear; the buttons appear at random; some form fields do not even have labels on them; and there is even a radio option for "Don't Send At All" selected by default which probably could be done away with entirely.

    For years I would develop forms just like this one. I would say that if the user did not understand my interface it was because they were too stupid to understand it. I was wrong.

    Gavin in Gavin-ish

    The term 'Gavin-ish' does not exist. I made it up. It is a term derived from the name Gavin, for Andy Gavin, co-creator of and developer of the successful Crash Bandicoot and Jax and Daxter video games for the old Sony Playstation 2. I do not think Andy is a Perl hacker at all. One of his posts called scripting languages 'toy' languages. Andy was a Lisp enthusiast who, in his own words, forced his game developers to use his Lisp engine to develop games. His website has an entire series on this. You might be wondering why in the world I would promote such a person here on this forum. Because I think some of the things he said about producing games are relevant for developing software as a whole. It certainly changed my outlook quite a bit. Here is the excerpt from his writing that I found most compelling:

    "...This is because games are all about gameplay, and good gameplay only comes from constant experimentation with and extensive reworking of the code that controls the game's objects."

    Take away the word 'game' and replace it with 'UI experience.'

    For years I avoided learning anything but very basic HTML/CSS/JavaScript because part of me resented the UI as a whole. I normally worked on the command line or in Emacs. I had to do a lot of figuring things out -- why should my end users not have to do the same? Well, if there are any benefits whatsoever to getting older one of them must be growing tired of wasted effort. Walking on proverbial eggshells every time you work with an interface is a sign that it is poorly designed. The whole point of a UI is to help the user avoid making mistakes. Organization of like things, spacing, grouping, color, and other tools all help make the user aware of what is to be done. None of those things require JavaScript.


    So in my quest to be a better coder I've started subscribing to this Neo-Gavin-ist philosphy (Neo because Andy is a Lisp and perhaps now a Ruby coder and not a Perl one). I now believe that UI design is about clarity and exhibiting both thoughtfulness and an assurance that a user's actions will result in proper/predictable outcomes.

    Consideration for things like spacing and grouping are not optional and must be used judiciously; size, color, emphasis, and even font choices are all relevant. Useless things should be removed (for instance, empty parenthesis...?) to enhance clarity. Rework of this type and kind Andy used to make some truly revolutionary games despite seemingly fantastic obstacles (memory constraints, unhelpful equipment vendor, etc.) and the same should be the goal for any UI.

    Granted, most of us are not making games. True, this type of rework takes time unless you have tools that do a lot of the heavy lifting for you. But doing nothing is just that and has a predictable and undesirable result. We can do better.

    Join my movement. Agree that UIs must subscribe to the philosophy of constant experimentation and rework for improvement irrespective of whether the underlying language is Perl or some other. Then develop better UIs, toolkits in Perl to make it easier to crank them out, and share your comments on this here.

    Celebrate Intellectual Diversity

Improve pipe open?
1 direct reply — Read more / Contribute
by afoken
on Apr 01, 2017 at 11:17

    A small meditation started by Ssh and qx


    Let's face it: qx is evil, as soon as you want to reliably pass arguments to a program. And it's not necessarily perl's fault. Blame the default shell. Luckily, perl has multi-argument pipe open since 5.8.0:

    open(my $pipe,'-|','/usr/local/bin/foo','bar','baz','1&2>3') or die "C +an't start foo: $!"; my @output=<$pipe>; close $pipe or die "Broken pipe: $!";

    It's so easy. Granted, it takes two more lines than qx, but we got rid of the default shell. And that two extra lines could easily be wrapped in a function:

    my @output=safe_qx('/usr/local/bin/foo','bar','baz','1&2>3');

    But, of course, that would be too easy to be true. Why can't we have nice things?

    Three-argument pipe open gets the nasty default shell back into play:

    > perl -E 'open my $pipe,"-|","pstree --ascii --arguments --long $$ 1> +&2" or die $!;' perl -E open my $pipe,"-|","pstree --ascii --arguments --long $$ 1>&2" + or die $!; `-sh -c pstree --ascii --arguments --long 22176 1>&2 `-pstree --ascii --arguments --long 22176 >

    Now what? We could resort to my favorite part of perlipc, "Safe pipe opens". 15 to 28 lines of code just to safely start an external program, and all of that only because perl wants to be clever instead of being safe.

    How to fix it

    Let's make multi-argument pipe open clever.

    system and exec have the indirect-object-as-executable-name hack to prevent the default shell mess. Applying that to open might be possible, but still looks quite hacky:

    open $list[0] my $pipe,'-|',@list or die "Can't open pipe: $!";

    No! Just no!

    So, do we really need to specify the executable twice? We usually don't want to lie to the target program about it's name. It might be useful to make a shell think that it's a login shell, but then again, that can also be done by passing an extra argument. No, we don't want to lie to our child process. If backwards compatibility was not a problem, we could simply disable the shell logic for any pipe open with more than two arguments. But for backwards compatibility, we can't do that. We need is a flag to disable the shell logic.

    My first idea was to just double the dash in the MODE argument:

    ModeActionUsage of default shell
    -|Read from child's STDOUTenabled for three argument open,
    disabled for more than three arguments passed to open
    (legacy mode)
    |-Write to child's STDIN
    --|Read from child's STDOUTdisabled
    |--Write to child's STDIN

    But we still can do better: A single bit is sufficient for a flag. + is already used in MODE, but not in combination with the pipe symbol. So let's use + instead of - to disable the default shell:

    ModeActionUsage of default shell
    -|Read from child's STDOUTenabled for three argument open,
    disabled for more than three arguments passed to open
    (legacy mode)
    |-Write to child's STDIN
    +|Read from child's STDOUTdisabled
    |+Write to child's STDIN

    Yes, I'm aware that the difference between "+" and "-" in ASCII is two bits.


    For a better mnemonic (ls -f uses "*" to indicate an executable file), we could use "*" instead of "-" to disable the default shell and specify the executable file in the third argument:

    ModeActionUsage of default shell
    -|Read from child's STDOUTenabled for three argument open,
    disabled for more than three arguments passed to open
    (legacy mode)
    |-Write to child's STDIN
    *|Read from child's STDOUTdisabled
    |*Write to child's STDIN

    Thanks to huck and hippo for finding two missing quotes.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
#p5p finds your lack of failing tests disturbing
3 direct replies — Read more / Contribute
by Corion
on Mar 27, 2017 at 13:42

    5.26 will come with a major change in how Perl builds and runs modules. The current directory will not be in @INC when running Perl programs.

    This affects all programs that call require or use and expect files relative to the current directory to be available. Besides plugin systems, any Makefile.PL using for example Module::Install is a likely offender. So far very little has been caught in the net of CPAN testers.

    As an example, one of my tests loads Makefile.PL:

    use lib '.'; use vars '%module'; require 'Makefile.PL'; # Loaded from Makefile.PL %module = get_module_info(); my $module = $module{NAME};

    This will fail under 5.26+ without the use lib '.'; statement at the top.

    I've altered @INC, pray I do not alter it further

    If you want to check whether your modules should still work and test OK under the upcoming 5.26 release, I think that the following oneliner should give you a good indication:

    perl -M-lib=. Makefile.PL && make && make test

    If you run author tests or prefer your tests to be run using prove, you have to take care of prove invoking a fresh Perl:

    # Windows syntax: set PERL5OPT=-M-lib=. perl Makefile.PL && dmake && prove -bl xt t
    @rem Shell syntax: export PERL5OPT=-M-lib=. perl Makefile.PL && make && prove -bl xt t

    Please test your distributions and release new versions if they need . in @INC. Thanks!

    Update: Added call to action and noted where use lib '.' helps.

[OT] Thoughts on Ruby's new absent operator?
5 direct replies — Read more / Contribute
by perlancar
on Mar 24, 2017 at 07:22
    Dear monks,

    Any thoughts on Ruby's new absent operator in its regular expressions (Hacker News thread)? Looks nifty to me and lets one specify more succinctly in some cases, although the things that it do can be done via other means.

Using PerlPod Creatively
4 direct replies — Read more / Contribute
by samijoseph
on Mar 24, 2017 at 03:21


    I am interested to understand what this guy did, but i am unable to, can someone please break it down to a newbie

    I've spent the last several days at work, trying to "take over" some work left behind by a departing colleague. I realized we didn't have some of his bash scripting in ansible or in a repo, so I decided this would be a good opportunity to fix all of those problems. After a little while it became clear his script was a set of functions, run in a loop-within-a-loop to iterate through a bunch of things. In the middle, between these two loops, is a pile of inline *PERL* that runs as a bash function and passes data back and forth in all directions. This Perl generates some dynamic SQL commands each loop.

    I hate SQL.

    Okay... read the Perl. Now, it's been a long time and a long way since my last string of PERLs, so i didn't really grok 100% what I was reading, but I got the gist of it. Finally figured out the SQL wasn't the problem.

    Another day goes by, and I finally figure out his code is self documenting! That was what all the little bits were in the perl I didnt get. PerlPod. So now I can figure this out easy . Run it, read the code, make a change, run it... *boom* what?


    It took me several more hours and a few beer, and it finally clicked. He was using PerlPod to document out the code he didn't want to run, and commented out the documenting code to run the code he wanted. What looked commented out, wasn't, and what looked like a pile of variables being set, was just a bunch of commentary. He was using a documentation module for *flow control*.

    What a Hacker. Holy shit. Blew. My. Mind.

    I just got schooled very seriously. It's nice to know I can still improve *that much*, even from where I am.

    When PerlPod is used to document something, anything between control codes is not interpreted but treated as commented text. He would comment out the control codes (thus rendering the text interpretable) on the parts meant to run, which would differ between machines.

OT: Got fired this week
15 direct replies — Read more / Contribute
by karlgoethebier
on Mar 23, 2017 at 05:43

    As i'm aged 60 + i guess i'll never get a new job. I think i need to face retirement. I first thought to delete my account on PM and through away all the code i ever wrote as well as my hand library and forget about everything related to programming. But it isn't so easy. I spent the last 20 years with this stuff. I'll stay a bit here - for fun. And perhaps i'll learn a new programming language ;-)

    Update: What should i say? I'm deeply moved. Thank you very much to all for encouragement and good advice.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    Furthermore I consider that Donald Trump must be impeached as soon as possible

What is a troll?
6 direct replies — Read more / Contribute
by trippledubs
on Mar 21, 2017 at 05:57

    Trolling is very powerful. It does not fool many here, but it CAN fool the unwary. Information is becoming consumed as such a fast pace that it becomes scary. Ideas are very powerful, but elders and young people must learn to build their character, use logic to question their own bias, work very hard to embrace change peacefully. Violence scares me because I'm a veteran and have seen what it can do. I will not take for granted that it can not happen here, but I will also not let fear rule my life. When it is used, must be used morally for self defense only. Many may question if to use this tool for selfish purposes during the coming years. The answer is no.

    I can not know if our leaders are moral, but people lose faith in their credibility anyways because they can not question them for themselves. Social contract is very important idea, but the future is here and social contracts are made with web sites, gives people a sense of belonging, and COMMUNITY is very important concept. But one must choose to belong in online communities that promote moral behavior.

    Question the rules, especially demagougery, embrace change peacefully. I think how stupid this game is, agree that it is just a list on the internet, but what if the desire to become on this list could show one 5 year old terrorists mind to learn perl instead of bomb making? Or show someone who was just fired; do this in the mean time and not worry too much. Your quality of life may suffer, but you can still belong to a community that values you. What certainly is true is that information can trigger a fight or flight mechanism in people. This scared me but, easily harnessed, just go exercise. Learn value of this game in US Military Monastery.

    A troll is someone who spreads fear, has no character to resist impulses, does not vote on evaluation of content, uses bias to marginalize others ideas instead of defeating them through reflection using logic, not ignore, this is bad way to defeat. There are many demagogues in the world that teach stupid ideas, people embrace them because they are scared, have little hope.

    I have studied in this school for 5 years, and it is my favorite online community! I would keep it sharp, use my talents to make it grow, make sure value is recognized. I think this xp game will be taken more seriously by millennials than you think. I also think pm will survive many efforts at marginalization, and I think perl will too. Because it is a great tool and there are years of evidence in the Monastery so people can judge for themselves. It is not which tool that is important as long as the tool you pick up is not used for violence|hacking.

Anyone using the new Test2 framework?
No replies — Read more | Post response
by stevieb
on Mar 19, 2017 at 16:56

    Quick opinion-related question on a slow, test-writing Sunday afternoon.

    Has anyone dabbled with the new Test2 framework at all? Are you using it in your CPAN and/or production projects?

    If so, what are your thoughts about it, and what are the pros/cons you've found so far?

Add your Meditation
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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (3)
    As of 2017-05-23 01:39 GMT
    Find Nodes?
      Voting Booth?