http://www.perlmonks.org?node_id=479

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
Catalyst app hangs httpd
1 direct reply — Read more / Contribute
by kenowen
on Jul 20, 2018 at 11:14
    This application is a web site (pace-cleanenergy.org) which has been posted on three servers before without problem. Now I'm trying to post on AWS. when I start httpd (apachectl) it looks fine until the end, and it hangs. The gbd backtrace at the hang is:
    #0 __strcasecmp_l_avx () at ../sysdeps/x86_64/multiarch/strcmp-sse42. +S:203 #1 0x00005572988d7234 in ap_find_command (name=name@entry=0x5572c91ea +f70 "\260}1\232rU", cmds=0x7f678ba3c890) at /usr/src/debug/httpd-2.2. +34/server/config.c:908 #2 0x00005572988d7289 in ap_find_command_in_modules (cmd_name=cmd_nam +e@entry=0x5572c91eaf70 "\260}1\232rU", mod=mod@entry=0x7ffce845ff50) at /usr/src/debug/httpd-2.2.34/server/config.c:924 #3 0x00005572988d73cd in ap_build_config_sub (p=p@entry=0x55729a24413 +8, temp_pool=temp_pool@entry=0x55729a250198, l=l@entry=0x55729fbc0708 + "\260}1\232rU", parms=parms@entry=0x7ffce8460040, current=current@entry=0x7ffce845 +ffb0, curr_parent=curr_parent@entry=0x7ffce845ffb8, conftree=conftree +@entry=0x7ffce8460018) at /usr/src/debug/httpd-2.2.34/server/config.c:1007 #4 0x00005572988d7ae2 in ap_build_config (parms=0x7ffce8460040, p=0x5 +5729a244138, temp_pool=0x55729a250198, conftree=0x7ffce8460018) at /usr/src/debug/httpd-2.2.34/server/config.c:1224 #5 0x00007f678b81af97 in modperl_config_insert () from /etc/httpd/mod +ules/mod_perl.so #6 0x00007f678b81b047 in modperl_config_insert_parms () from /etc/htt +pd/modules/mod_perl.so #7 0x00007f677da1283a in ?? () from /usr/lib64/perl5/vendor_perl/auto +/Apache2/CmdParms/CmdParms.so #8 0x00007f678b536ee7 in Perl_pp_entersub () from /usr/lib64/perl5/CO +RE/libperl.so #9 0x00007f678b52f776 in Perl_runops_standard () from /usr/lib64/perl +5/CORE/libperl.so #10 0x00007f678b4c7ca0 in Perl_call_sv () from /usr/lib64/perl5/CORE/l +ibperl.so #11 0x00007f678b81d429 in modperl_callback () from /etc/httpd/modules/ +mod_perl.so #12 0x00007f678b81c3d0 in modperl_cmd_perldo () from /etc/httpd/module +s/mod_perl.so #13 0x00005572988d5816 in invoke_cmd (cmd=0x7f678ba3c480, parms=parms@ +entry=0x7ffce84609f0, mconfig=0x55729a2c5158, args=0x55729a2a40a0 "#\tuse lib '/home/ec2-user/.cpan/build/Text-S +impleTable-2.05-LibLQW/lib/';\nuse lib '/home/ec2-user/perl5/lib/perl +5';\nuse lib '/var/www/html/new.pace-cleanenergy.org/httpdocs/PACE/li +b';\nuse PACE;\n#print"...) at /usr/src/debug/httpd-2.2.34/server/con +fig.c:757 #14 0x00005572988d79c7 in ap_walk_config_sub (section_vector=0x55729a2 +c1b88, parms=0x7ffce84609f0, current=0x55729a2a4178) at /usr/src/debug/httpd-2.2.34/server/config.c:1163 #15 ap_walk_config (current=0x55729a2a4178, parms=parms@entry=0x7ffce8 +4609f0, section_vector=0x55729a2c1b88) at /usr/src/debug/httpd-2.2.34 +/server/config.c:1196 #16 0x00005572988cf88a in virtualhost_section (cmd=0x7ffce84609f0, dum +my=<optimized out>, arg=<optimized out>) at /usr/src/debug/httpd-2.2. +34/server/core.c:2259 #17 0x00005572988d5816 in invoke_cmd (cmd=0x557298aff6f0 <core_cmds+80 +>, parms=parms@entry=0x7ffce84609f0, mconfig=0x55729a24fb90, args=0x5 +5729a2a39c0 "*:80>") at /usr/src/debug/httpd-2.2.34/server/config.c:757 #18 0x00005572988d79c7 in ap_walk_config_sub (section_vector=0x55729a2 +4f770, parms=0x7ffce84609f0, current=0x55729a2a3980) at /usr/src/debug/httpd-2.2.34/server/config.c:1163 #19 ap_walk_config (current=0x55729a2a3980, parms=parms@entry=0x7ffce8 +4609f0, section_vector=0x55729a24f770) at /usr/src/debug/httpd-2.2.34 +/server/config.c:1196 #20 0x00005572988d8812 in ap_process_config_tree (s=s@entry=0x55729a24 +e440, conftree=<optimized out>, p=0x55729a244138, ptemp=<optimized ou +t>) at /usr/src/debug/httpd-2.2.34/server/config.c:1765 #21 0x00005572988c05e5 in main (argc=3, argv=0x7ffce8460c58) at /usr/s +rc/debug/httpd-2.2.34/server/main.c:665
    The virtual host configuration is:
    <VirtualHost *:80> ServerAdmin kenowen@eowen.com ServerName pace-cleanenergy.org ServerAlias www.pace-cleanenergy.org DocumentRoot /var/www/html/new.pace-cleanenergy.org/httpdocs/PACE +/root ErrorLog logs/pace-cleanenergy.org-error_log CustomLog logs/pace-cleanenergy.org-access_log common #modperl config <Perl> use lib '/home/ec2-user/perl5/lib/perl5'; use lib '/var/www/html/new.pace-cleanenergy.org/httpdocs/PACE/ +lib'; use PACE; </Perl> <Location /> SetHandler ModPerl PerlResponseHandler PACE </Location> #modperl end </VirtualHost>
/perl5.10/bin and linux
3 direct replies — Read more / Contribute
by yaklichk0719
on Jul 20, 2018 at 10:57
    I saw this in the bash_profile some setting: /perl5.10/bin for CentOS 6.3, where is my centOS 6.6 I find this: /usr/bin/perl. I am assuming this is where Perl executive are kept by default? I am trying to understand why in the first case they use it this way and does it make a difference when use Perl libraries in a packages? Thank you, Sergey
Constants lists in array slices
4 direct replies — Read more / Contribute
by LanX
on Jul 20, 2018 at 07:40
    The following code is surprising me in two ways:

    use strict; use warnings; use feature 'say'; use constant FL => 17,3,16; use constant FL2 => 22,4,13; my @row= "a".."z"; my @a = (" ") x 26; @a[17,3,16] = @row[22,4,13]; say "@a"; @a = (" ") x 26; @a[FL()] = @row[FL2]; say "@a";

    It seems like constant folding isn't happening at all!!!

    • I get a warning for FL2
      Scalar value @row[FL2] better written as $row[FL2] (ignoring that its a constant _list_)
    • Deparsing the code shows that FL and FL2 are called as functions
      @a[FL()] = @row[FL2()];
    Am I missing something?

    (This is perl 5, version 16,)

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

Writing IBM Mainframe floating point
2 direct replies — Read more / Contribute
by caden_varn
on Jul 20, 2018 at 06:19
    I need to create a file including single precision floating point fields in the IBM mainframe format (specifically to be read by the SAS s370frb4. informat). I am on an HP-UX 11 box which evidently uses a different floating point - when I use pack's 'f' option the value changes when read in by the SAS program on the other end. Is there an option or module that can do this easily? Any help greatefully received...
get text from node - XML::LibXML
2 direct replies — Read more / Contribute
by corfuitl
on Jul 20, 2018 at 05:36

    Hi all

    I have the XML file

    <seg><foo mid="0" mtype="seg"><g id="1">Need to export this text</g></foo></seg>

    and I would like to get the text with its XML tags (i.e. <g id="1">Need to export this text</g>

    for my $foo ($seg->findnodes('foo')) { my $mid = ($foo->findvalue('@mid')); my $mrktext = ($foo->findnodes('text()')); print "$mid $mrktext\n"; }

    I use this but it doesn't export any text.

Loading modules remotely
5 direct replies — Read more / Contribute
by bliako
on Jul 20, 2018 at 05:29

    Dear Monks,

    I would like to know if there is already a Perl module which provides a network server for serving Perl modules from a remote location and a directive to be embeded in a perl script so as to load said modules from the server. Preferably using encryption.

    For example,

    use Module::X from 192.32.43.45:7777 ssh='.ssh/id_rsa';

    thanks, bliako

Perl dictionary
5 direct replies — Read more / Contribute
by dideod.yang
on Jul 19, 2018 at 20:03
    Hi monks. I am perl & python lover.. recently I made many scripy using perl.. So I want to know many functions as much as possible. Cpan give me many information about modules.. but function is not.. Do you monks have nice website? or manual? about perl function??
site_perl files
3 direct replies — Read more / Contribute
by yaklichk0719
on Jul 19, 2018 at 17:00
    Can somebody please explain me what should be in the folder perl5.10/lib/site_perl/? I have perl 5.10.1 under centOS 6.6 and it does not have site_perl. Another package that I have been been trying to run requires the presence of this path perl5.10/lib/site_perl. Where can I download files for this site_perl? Please help me to figure this out. I really appreciate it.
occurence of repeated numbers group
5 direct replies — Read more / Contribute
by satya02
on Jul 19, 2018 at 09:42

    Please help me in finding occurence of repeated numbers group.

    Example input:

    1 2 5 9

    1 2 5 10

    4 5 10 12

    5 9 10 11

    output:-

    1 2 repated 2 times

    2 5 repeated 2 times

    5 10 repeated 3 times

I need help installing DBD:Oracle and DBD
1 direct reply — Read more / Contribute
by gandolf989
on Jul 19, 2018 at 09:33

    I am trying to install DBD:Oracle and DBD so that I can write a script to clean up some attachments with our primary database, and change the pointers to show that the attachments are gone. But I ran into an issue with the above packages. I tried the initial install using cpan. but I did not have the environment variables set, so it did not compile correctly. I would like to remove and reinstall the packages, or mostly just get them working. I do have an 11.2.0.4 Oracle client on the server. But I will be connecting to another server for the database.

    Can someone point me in the right direction. The server is Redhat 6.8. Thanks

    $:~/ ./runMyPerlScript.pl Can't load '/usr/local/lib/perl5/site_perl/5.28.0/x86_64-linux/auto/DB +I/DBI.so' for module DBI: /usr/local/lib/perl5/site_perl/5.28.0/x86_6 +4-linux/auto/DBI/DBI.so: undefined symbol: PL_sv_immortals at /usr/li +b64/perl5/DynaLoader.pm line 200. at /usr/local/lib/perl5/site_perl/5.28.0/x86_64-linux/DBI.pm line 284 +. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +28.0/x86_64-linux/DBI.pm line 284. Compilation failed in require at /usr/local/lib/perl5/site_perl/5.28.0 +/x86_64-linux/DBD/Oracle.pm line 20. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +28.0/x86_64-linux/DBD/Oracle.pm line 20. Compilation failed in require at /home/oracle/scripts/purge_proddoc_sc +ript/purge_proddoc_script.pl line 16. BEGIN failed--compilation aborted at /home/oracle/scripts/purge_proddo +c_script/purge_proddoc_script.pl line 16 (#1) (F) The module you tried to load failed to load a dynamic extensio +n. This may either mean that you upgraded your version of perl to one that + is incompatible with your old dynamic extensions (which is known to h +appen between major versions of perl), or (more likely) that your dynami +c extension was built against an older version of the library that i +s installed on your system. You may need to rebuild your old dynamic extensions. Uncaught exception from user code: Can't load '/usr/local/lib/perl5/site_perl/5.28.0/x86_64-linux +/auto/DBI/DBI.so' for module DBI: /usr/local/lib/perl5/site_perl/5.28 +.0/x86_64-linux/auto/DBI/DBI.so: undefined symbol: PL_sv_immortals at + /usr/lib64/perl5/DynaLoader.pm line 200. at /usr/local/lib/perl5/site_perl/5.28.0/x86_64-linux/DBI.pm line 284 +. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +28.0/x86_64-linux/DBI.pm line 284. Compilation failed in require at /usr/local/lib/perl5/site_perl/5.28.0 +/x86_64-linux/DBD/Oracle.pm line 20. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5. +28.0/x86_64-linux/DBD/Oracle.pm line 20. Compilation failed in require at /home/oracle/scripts/purge_proddoc_sc +ript/purge_proddoc_script.pl line 16. BEGIN failed--compilation aborted at /home/oracle/scripts/purge_proddo +c_script/purge_proddoc_script.pl line 16. at /home/oracle/scripts/purge_proddoc_script/purge_proddoc_script.pl +line 16. $:~/scripts/purge_proddoc_script > cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.8 (Santiago)
    #!/usr/bin/perl use strict; use warnings; use diagnostics; package purge_proddoc_script; use Getopt::Std; # use Sys::Hostname; use POSIX qw(setuid setgid); use English; use Carp; use Cwd 'abs_path'; use DBD::Oracle qw(:ora_session_modes); use DBI; use File::Basename; use IO::Handle; use Log::Log4perl qw( :easy ); use Text::Diff; local $SIG{__WARN__} = \&Carp::cluck; $SIG{__DIE__} = sub { # return if $^S; # ignore die in an eval block # Get the actual caller for the "die" and not the wrapper local $Log::Log4perl::caller_depth; $Log::Log4perl::caller_depth++; LOGDIE($_[0]); }; # possible log values: DEBUG, INFO, WARN, ERROR, FATAL my $debug_level="INFO"; # my $error_mail_list='bbyrd@aires.com, ASayed@aires.com, vkamins@aire +s.com, RKatru@aires.com'; my $error_mail_list='bbyrd@aires.com'; # Unbuffer STDOUT and STDERR select STDERR; $| = 1; select STDOUT; $| = 1;

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.