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

The Monastery Gates

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

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

Quests
poll ideas quest 2021
Starts at: Jan 01, 2021 at 00:00
Ends at: Dec 31, 2021 at 23:59
Current Status: Active
5 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
The Perl and Raku Conference 2021 online
on Jun 08, 2021 at 02:55
0 replies by Discipulus
    Hello folks!

    today starts the The Perl and Raku Conference, Conference in the Cloud, at 11:30 New York time (16:30 GMT).

    You can see how-to-attend-this-conference and the whole scheduling.

    Profit it!

    L*

    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.
Perl questionaire by Gobby
on Jun 02, 2021 at 03:54
6 replies by Tux

    A shared Vision of Perl

    Hello!

    Welcome to the survey on a shared vision of Perl!

    Gobby is an innovative, Perl-based, survey tool. We're committed to the future of the Perl ecosystem and people that make up these communities.

    We're looking for support in the development of Gobby as a Perl product. Please drop us a line to info@gobby.io if you like our approach to surveys and would like to be part of Gobby's future.

    Best wishes,

    Gary Beckwith
    Founder of Gobby


    Enjoy, Have FUN! H.Merijn
Supplications
how to iterate directory
3 direct replies — Read more / Contribute
by rajand
on Jun 22, 2021 at 14:09
    How to iterate directories.

    eg. d1,d2,d3,d4 and d5 are the 5 directories

    Wanna iterate the directories and process a single file from each directory using system command cut and write the output inside the directory itself. please guide me...TIA

Native Map faster than MCE::Map.
1 direct reply — Read more / Contribute
by Anonymous Monk
on Jun 21, 2021 at 12:05

    Hi Monks

    I'm playing with MCE::Map to see if it's really faster than native map, but so far, native map seems to be faster...What am I doing wrong?

    use strict; use warnings; use Time::HiRes qw (gettimeofday tv_interval); my @bignum = (1..100000000); my $native_map_start_time = [gettimeofday]; my @native_map = map { $_ * $_ } @bignum; my $native_elapsed_time = tv_interval($native_map_start_time); printf "The elapsed time with native map is %2.2f seconds\n", $native_ +elapsed_time;

    The output is:

    $ perl native_map.pl The elapsed time with native map is 8.57 seconds

    When I try the same with the MCE::Map, it takes longer than native map.

    use strict; use warnings; use MCE::Map; use Time::HiRes qw (gettimeofday tv_interval); my $mce_start_time = [gettimeofday]; my @mce_map = mce_map_s { $_ * $_ }1, 100000000; my $mce_elapsed = tv_interval($mce_start_time); printf "The elapsed time with MCE::map (mce_map_s) is %2.2f seconds\n" +, $mce_elapsed;

    This takes way longer:

    perl mce_map.pl The elapsed time with MCE::map (mce_map_s) is 25.34 seconds

    When I run this on Perl 5.16.3, both the times are almost double. With 5.32.0 though, I get the outputs given above.

    I am trying these on a laptop with Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz Processor and 16 GB RAM running Debian Buster with backported kernel as shown below:

    uname -rv 5.10.0-0.bpo.7-amd64 #1 SMP Debian 5.10.40-1~bpo10+1 (2021-06-04)
How to get all shared libs of a path?
2 direct replies — Read more / Contribute
by ovedpo15
on Jun 20, 2021 at 12:54
    Hello Monks!
    This question is more sort of a code-review. I'll explain what I'm trying to do.
    I'm using Linux env. I'm looking for a way to get all shared libraries of path. So basically something like:
    %libs = get_libs($path);
    Now I'm trying to figure out how I need to create my own `get_libs` sub or is there already a made basic module I should use (which probably will do a better job than me, but it should be pretty basic since it is really hard to make IT to install the module on all the machines). Looked at CPAN first and found out Devel::SharedLibs which looks like something similiar but it is not installed in IT.
    The way I thought of implementing the `get_libs` sub is by using:
    ldd <path>
    And then parsing the output of it. Although I'm only working on Linux SUSE, the problem is it's bad practice to parse some command's output. For example at some point, the format could change. If there was an option like `--json` or some other formatting option, to get the output as JSON and then you know how to parse it, then it would be better. But the output of `ldd` is:
    linux-vdso.so.1 (0x00007ffff733a000) + libems_sh.so => not found + libdl.so.2 => /lib64/libdl.so.2 (0x00007ffff7b337000) + libtq.so => not found
    I could parse this output like so:
    my $cmd = "ldd $path"; my ($stdout, $stderr, $exit_status) = capture { system($cmd); }; next if (exit_status); foreach my $line (split(/\n/, $stdout)) { if ($line =~ /(.*)\s*=>\s*(.*)/) { my $lib_path = $2; if ($lib_path =~ /(.*)\s+(.*)/) { $lib_path = $1; $paths{$lib_path}++; print("Found $lib_path of $path\n"); } else { print("Invalid line: $line of $path\n"); } } else { print("Invalid line: $line of $path\n"); } }
    I really don't like my code. It feels too specific (I look for strings of -something- => -someting- -something- basically). Is it possible to review my code and suggest improvements or other ideas on how to solve this challenge?
Using relative paths with taint mode
3 direct replies — Read more / Contribute
by Bod
on Jun 19, 2021 at 13:27

    I'm taking my first tentative steps into using taint mode!
    A problem has quickly got me rather stuck...

    I want to use a module in a relative path but taint mode removes '.' from @INC
    If I do this:

    #!/usr/bin/perl -T use CGI::Carp qw(fatalsToBrowser); use Site::HTML; use strict; use warnings;
    It complains that Site::HTML cannot be found.
    So I called on FindBin to help like this:
    #!/usr/bin/perl -T use CGI::Carp qw(fatalsToBrowser); use FindBin qw($Bin); use lib "$Bin"; use Site::HTML; use strict; use warnings;
    But now get an error Insecure dependency in require while running with -T switch at migrate.pl line 7.

    Is this the correct way to load a relative module under taint mode?
    Is the problem with the way I am loading the module or with the module itself?
    Should I be doing something completely differently?

Issue with LWP loading client certificate
4 direct replies — Read more / Contribute
by ffrost
on Jun 17, 2021 at 16:04

    Objective: To connect from my machine to an external server using HTTPS. The connection will use the GET verb and the external server should return a message back to the client. As a security mechanism, the certificate for my client must be sent to the server as authentication.

    I'm using LWP to get the response from the external server. I've run into two problems I'm not sure of. First, I am unsure if the LWP program is actually loading the certificate, which is in DER format. Second, since the server is responding with a 403 error I don't think they are getting my certificate. Am I loading the certificate correctly to send from my Windows machine to their external IIS server?

    The DER certificate is valid and has not expired. It is not a self-signed certificate.

    use LWP::UserAgent; use Data::Dumper; use Cwd; $cdir = getcwd; $endpoint = ‘https://omit/commotest'; $ua = LWP::UserAgent->new; $ua->ssl_opts(SSL_cert_file => "$cdir\\der.cer"); $ua->ssl_opts(SSL_use_cert => '1'); $response = $ua->get($endpoint); if ($response->is_success) { print Dumper $response; } else { print "Error: " . $response->status_line, "\n"; }
Mojo pp html_entities.txt
1 direct reply — Read more / Contribute
by Anonymous Monk
on Jun 17, 2021 at 12:45

    How can I override at run time the directory where Mojo searches for the file "html_entities.txt"? The reason is that I am trying to use PAR pp to create an executable of an application using Mojo on Windows 10, but the exe fails with the following error:

    Unable to open html entities file (C:\Users\de\AppData\Local\Temp\par-6663\cache-9973dd41d00e8bee27c9630746780ae38da71709\inc\lib\Mojo\resources\html_entities.txt): No such file or directory at C:\Users\de\AppData\Local\Temp\par-6663\cache-9973dd41d00e8bee27c9630746780ae38da71709\inc\lib/Mojo/Base.pm line 14.

    I already tried to add to the file explicitly:

    -a "C:\Strawberry\perl\vendor\lib\Mojo\resources;Mojo/resources"

    with no effect. So probably copying and pasting the file into my data structure and instruct Mojo to search there could be a fix. Any suggestion?

how to ignore spaces, commas or new line of an array when comparing
1 direct reply — Read more / Contribute
by noviceuser
on Jun 16, 2021 at 04:01

    I am trying to compare two arrays which may have strings/elements separated by newline, spaces or comma, how can i ignore those special characters while comparing

    e.g: suppose @array1 has contents like below

    abc xyz

    and @array2 has contents like below

    abc xyz
    my $comp = Array::Compare->new; if ($comp->compare(\@array1, \@array2)) { print "array same\n"; } else { print "array not same\n"; }
Meditations
Organizational Culture (Part II): Meta Process
1 direct reply — Read more / Contribute
by eyepopslikeamosquito
on Jun 17, 2021 at 06:03

    Googling Organizational Culture revealed many folks offering (often pricey) Organizational Culture workshops based on theories concocted by a pair of enterprising boffins, quietly contemplating at the University of Michigan, located in the picturesque village of Ann Arbor.

    Though the definitive reference on their work is available for purchase from amazon, you can also get a feel for their process by reading this early paper:

    A Process for Changing Organizational Culture by Kim Cameron, University of Michigan 2008
    Handbook of Organizational Development, 2008: 429-445 (cited by 345)

    Abstract: This chapter outlines a process for diagnosing and changing organizational culture. It uses the Competing Values Framework to describe a validated approach to helping an organization change from a current culture to a desired culture.

    ... and from the (mostly youtube) links in the References section below. As you might expect, I was too cheap to pay for advice on this topic, so instead watched some youtube videos and read Kim's original paper. Though not necessarily the best organizational change process (alternative citations welcome), at least this is a concrete thing that can be discussed and analysed, and thus serve as a starting point for discussing specific ways to improve Organizational Culture (and Perl organizational culture too).

    For those seeking a Perl Monks connection to this academic paper, notice that Ann Arbor Michigan is a mere two hour scenic drive from Hope College in Holland Michigan, the sacred birthplace of Perl Monks (if you drive via Portage Michigan, you can further pick up some COVID-19 vaccines from Pfizer’s huge manufacturing facility on the way).

    Definition of Organizational Culture

    Although many definitions of culture have been proposed, the two main disciplines are:

    • Sociological (organizations have cultures). Assumes you can identify differences among organizational cultures, can change cultures, and can empirically measure cultures.
    • Anthropological (organizations are cultures). Assumes that nothing exists in organizations except culture, and one encounters culture anytime one rubs up against any organizational phenomena.

    In her 2008 paper, Cameron gave a popular and practical definition of culture as:

    the taken-for-granted values, underlying assumptions, expectations, and definitions present which characterize organizations and their members
    which:
    • serves as the social glue binding an organization together; and
    • represents how things are around here, affects the way members think, feel, and behave.

    and further perceptively noticed that:

    With very few exceptions, virtually every leading firm has developed a distinctive culture that is clearly identifiable by its key stakeholders

    This distinctive culture is sometimes created by the initial founder: Walt Disney, Bill Gates, and Larry Wall, for example. All three of these legends developed something special, something more vital than corporate strategy, market presence, or technical advantages: the power that arises from a unique and spirited culture.

    Curiously, most people are unaware of culture until suddenly confronted with a different one: travelling to Vietnam, for example, finding yourself immersed in different noises and smells and unable to understand a word of the local lingo ... or asking a question on SO after years of posting at Perl Monks. :)

    The culture of most organizations is invisible, most members have a hard time describing it, let alone consciously changing it -- that is why you need tools, such as The Competing Values Framework and the Organizational Culture Assessment Instrument (OCAI), developed by scholars Cameron and Quinn.

    Notice that Organizational Climate is distinct from Organizational Culture: Climate is temporary, Culture enduring.

    The Competing Values Framework

    This framework, used to assess the dominant characteristics of organizations, differentiates on two vertical dimensions:

    1. Flexibility, Discretion, Dynamism (effective if: changing, adaptable, organic, e.g. Google, Nike)
    2. Stability, Order, Control (effective if: stable, predictable, mechanistic, e.g. Universities, Government agencies, Boeing)

    and two horizontal dimensions:

    1. Internal orientation, Integration, Unity (harmonious internal characteristics, e.g. IBM, the IBM way)
    2. External orientation, Differentiation, Rivalry (effective if: competing with others outside their boundary, e.g. Toyota, Honda)

    Together these two dimensions form four quadrants:

    1. Clan culture (Collaborate)
    2. Adhocracy culture (Create)
    3. Hierarchy culture (Control)
    4. Market culture (Compete)

    Hierarchy Culture:

    • Formalised and structured workplace. Procedures and controls govern what people do. Leaders: coordinators, organizers, monitors.
    • Maintaining a smoothly running organization is important.
    • Long term: stability, predictability, efficiency, formal rules and policies hold the organization together.
    • Success is defined in clear lines: authority, control, accountability, e.g. McDonalds, Govt agency on airport controls (strict guidelines for every small detail).

    Market Culture:

    • Competing environment, results-oriented workplace, external environment is hostile, consumers are selective, want value.
    • Leaders are hard-driving producers; competitors are tough and demanding.
    • Productivity, results and profits; glue is emphasis on winning.
    • Success is market share and penetration, e.g. Ikea, Walmart.

    Clan Culture:

    • Friendly workplace, people share a lot of themselves, leaders are mentors, facilitators, team builders, parent figures, held together by loyalty and tradition.
    • Commitment is high, long-term benefit of individual development, high cohesion and morale important.
    • Success is defined as internal climate and concern for people, premium on teamwork, participation and consensus, e.g. small family-owned companies, doctors without borders, wikipedia.

    Adhocracy Culture:

    • Dynamic, entrepreneurial culture, people take risks, leaders: visionary, innovative, risk-oriented.
    • Glue: Commitment to experimentation and innovation, to be at the leading edge, readiness for change is essential.
    • Long term emphasis is rapid growth.
    • Success is creating unique & original products and services, e.g. start-ups.

    Relationship between the four quadrants:

    • Each side represents opposites
    • Flexibility vs Stability
    • Internal vs External
    • Competing on the Diagonal: Clan (internal focus) v Market (external focus); Adhocracy (external organic) v Hierarchy (internal control)
    The competing on opposite sides of each quadrant give rise to the name of the model.

    Why Change Organizational Culture?

    The Competing Values Framework Introduction youtube (around the 12:15 mark) gives a fascinating case study of how Organizational Cultures change over time. Steve Jobs, a charismatic entrepreneurial leader, was a great cultural fit for the (Startup culture) Apple of the 1970s ... only to get fired in 1985 for his chaotic management style, when Apple needed more controls and standard procedures ... then finally re-hired in 1997 to heroically resurrect the company after it started having a hard time inventing new products! That is, Apple culture evolved from Adhocracy (Apple II era) to Adhocracy/Clan (Macintosh era) to Hierarchy (John Scully era) to Hierarchy/Market then balanced Hierarchy/Market/Adhocracy/Clan (on Jobs return).

    How does a language win? By being compelling enough to be used for new things. It's not solely a technical concern; it's a concern of the language community and ecosystem.

    -- Why Perl Didn't Win (essay from outspeaking.com)

    As indicated in the essay cited above, a good reason for Perl to change its culture may be to make it more attractive for new projects (compared to competing languages).

    Of course, if Perl was a commercial enterprise, one business strategy to cope with losing market share may be to seek a merger with Python ... thus allowing our new customers to write some truly astonishing code:

    # copy stdin to stdout, except for lines starting with # while left_angle_right_angle: if dollar_underscore[0] =eq= "#": continue_next; } print dollar_underscore; }

    Sorry, couldn't resist. :)

    Note that if you choose not to attempt to explicitly change your organization's culture, it will change anyway. Culture is evolving all the time.

    The Seven Steps To Culture Change

    1. Clarifying meaning.
    2. Identifying stories.
    3. Determining strategic initiatives.
    4. Identifying small wins.
    5. Crafting metrics, measures, and milestones.
    6. Communication and symbols.
    7. Leadership development.

    The Organizational Culture Assessment Instrument (OCAI)

    It might be fun to create a Perl Monks poll to see how people rate P5P culture or Perl Monks culture.

    1. DOMINANT CHARACTERISTICS
    The organization is:
    A. a very special place. It is like an extended family. People seem to share a lot of themselves.
    B. a very dynamic and entrepreneurial place. People are willing to stick their necks out and take risks.
    C. very production oriented. A major concern is with getting the job done. People are very competitive and achievement oriented.
    D. a very formalized and structured place. Bureaucratic procedures generally govern what people do.

    2. ORGANIZATIONAL LEADERS
    The leaders of the organization are generally considered to be:
    A. mentors, facilitators, or parent figures.
    B. entrepreneurs, innovators, or risk takers.
    C. hard-drivers, producers, or competitors.
    D. coordinators, organizers, or efficiency experts.

    3. MANAGEMENT OF EMPLOYEES
    The management style in the organization is characterized by:
    A. teamwork, consensus and participation.
    B. individual risk-taking, innovation, flexibility, and uniqueness.
    C. hard-driving competitiveness, goal directedness, and achievement.
    D. careful monitoring of performance, longevity in position, and predictability.

    4. ORGANIZATION GLUE
    The glue that holds the organization together is:
    A. loyalty and mutual trust. Commitment to this organization runs high.
    B. orientation toward innovation and development. There is an emphasis on being on the cutting edge.
    C. the emphasis on production and goal accomplishment. Marketplace aggressiveness is a common theme.
    D. formal rules and policies. Maintaining a smooth running organization is important.

    5. STRATEGIC EMPHASES
    The organization emphasizes:
    A. human development. High trust, openness and participation persist.
    B. acquiring new resources and meeting new challenges. Trying new things and prospecting for new opportunities are valued.
    C. competitive actions and achievement. Measurement targets and objectives are dominant.
    D. permanence and stability. Efficient, smooth operations are important.

    6. CRITERIA OF SUCCESS
    The organization defines success on the basis of:
    A. development of human resources, teamwork, and concern for people.
    B. having the most unique or the newest products. It is a product leader and innovator.
    C. market penetration and market share. Competitive market leadership is key.
    D. efficiency. Dependable delivery, smooth scheduling, and low cost production are critical.

    Other Articles in This Series

    References

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 imbibing at the Monastery: (3)
As of 2021-06-23 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (110 votes). Check out past polls.

    Notices?