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

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
PDF::API2 behaving differently on two computers?
2 direct replies — Read more / Contribute
by trillich
on Apr 08, 2020 at 13:42

    Having issues with PDF::API2. We are creating PDF output starting with a watermark/background (lines for the form and a bitmap logo) and then overlay text on top. The database text overlay never has any trouble. It's the background PDF we are wrestling with.

    Computer 1: template.pdf is read in by the script, we overlay the text, all is well with the generated PDF. The background form and logo show up with the text on top, just as expected.

    Computer 2: template.pdf is read in by the script, and only part of it renders properly in the final PDF. The overlay text renders just fine, so I don't think the PDF gets entirely corrupted. The template files are identical on both computers.

    #1 has PDF::API2 version 2.023 and #2 has 2.033, so I thought maybe I could downgrade. But testing with v2.023 on #2 has the same problem.

    Experimented with dozens of variations on the template file. Made a simple 3-rectangle background in Illustrator as the template, and that worked fine. Added a white blob with bezier curves on top of the rectangles, updated the template, and then none of the rectangles showed up, either, as if the whole template was empty. Removed the blob and added a white oval (which is also bezier curves), and that worked 100% fine. So far I can't find the pattern.

    So I'm concluding that somewhere between my $bg = $pdf->importPageIntoForm( $bg, 1 ); and $page->gfx->formimage( $bg, 0, 0, 1.0 ) something is going south on #2 but not on #1. Right?

    Suggestions on how to troubleshoot this are welcome. :/

.VCF records cleansing
3 direct replies — Read more / Contribute
by solocazzimiei
on Apr 08, 2020 at 05:51
    Hi to all, ...and sorry for bad post formatting but PerlMonks seems don't recornize \n statement..

    Here we are: after had accumulate lots of .vcf files were inside of each are plenty of duplicated records, I'm working on custom script for rationalize,merging & cleansing over 700k records.

    I stuck on find universal solution for splits fields from records like this :

    $in[$x]="NOTE;ENCODING=QUOTED-PRINTABLE:=0AAddress:=0A=0Aor. Soroca=0A +Republic of Moldova=0A=0A=0A=0A Footwear. =Children's footwear. Lady' +s footwear."

    using code like:

    $in[$x] =~ /(\w+\W?\w*\W?\w*\W?\w*\W?\w*\W?\w*\W*?\w*\W*?\w*\W*?\w*)\: +(=?0?.+:*)/; $a =$1;$2; $a =~ s/;X-SYNCMLREF\d+//; $key{$a} = $a;
    This script work fine on almost the VCF's lables like : N, FN, ORG, TEL, etc.. but in record frame like above I obtain splitting on the lastest \: instead of first one, despite use of non greedy techniques:
    $1 = "NOTE;ENCODING=QUOTED-PRINTABLE:=0AAddress" $2 = "=0A=0Aor. Soroca=0ARepublic of Moldova=0A=0A=0A=0A Footwear. =Ch +ildren's footwear. Lady's footwear."
    Any suggestions ? Thks
Where is documenation for defining servers for use by Rex?
3 direct replies — Read more / Contribute
by nysus
on Apr 07, 2020 at 17:24

    I'm having trouble locating documentation that explains how to set up servers for use in Rex scripts. Can someone please point me in the right direction? Thanks.

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

Override new in Moose for flyweight objects
2 direct replies — Read more / Contribute
by Aaronrp
on Apr 07, 2020 at 14:15

    I've found the module MooseX::Role::Flyweight a useful one for keeping a cache of objects, but I've never been happy with the way it requires you to use Class->instance(y => 'x') instead of Class->new(y => 'x') to get the new object. What if I change my mind about caching, or want to debug the code without the cache? Then I have to find all the calls in all my code and change them. What if I miss one, and call new from outside the class? So much for the cache.

    I came up with this alternative approach, which seems to work. It overrides Moose's new method but still inlines the constructor.

    package TestNew 0.001; use Moose; has thingy => ( required => 1, is => 'ro', ); my %obj_cache; override 'new' => sub { my ( $class, @args ) = @_; my $params = $class->BUILDARGS(@args); # from Moose::Object my $thingy = $params->{thingy}; my $cachekey = $thingy; if ( exists $obj_cache{$cachekey} ) { return $obj_cache{$cachekey}; } return $obj_cache{$thingy} = $class->_new( thingy => $thingy ); }; *Moose::Object::_new = \&Moose::Object::new; __PACKAGE__->meta->make_immutable( constructor_name => '_new' ); 1;

    Other than the unfortunate need to mess around inside the Moose::Object namespace, I don't see any huge downsides, but I must admit I don't really know what I'm looking at when I poke around inside Class::MOP::Class and was wondering if others had thoughts.


Parsing Emacs Lisp sexpr?
3 direct replies — Read more / Contribute
by perlancar
on Apr 07, 2020 at 13:41
    Wondering if there's something on CPAN or elsewhere which can parse the contents of into a reasonable Perl representation? I think Data::SExpression chokes on bracket character and that module seems to be pretty much what CPAN has to offer for something relating to parsing S-expression. I guess whipping up a new parser is not hard...
Invokes perl modules from perl script in different perl versions
2 direct replies — Read more / Contribute
by maria80e
on Apr 07, 2020 at 13:33

    We have two versions of Active perl 5.6 and 5.24. We have web services which is written as perl modules to be executed on Active perl '5.24' versions(to adopt TLS 1.2 version) and this needs to be invoked from Active perl '5.6' version.

    Is there any feasibility to do the following Main Program runs on 5.6 version perl modules to be executed in 5.24 version Perl modules are invoked by main program which runs on 5.6 version.

    For the below example,

    Example:- (5.6 version) use webser; my $result = qx{C:/Perl_524/bin/perl.exe D:/};

    Expected Result: the expected result is Main program which runs on 5.6 invokes the perl module which has to be run on 5.24 version and returns the result.

    During the execution we noticed that the perl modules runs on 5.6 instead of executing on 5.24.


    1. The input paramter for the web services are binded in the object created for the module

    2. we tried system command too and its not worked as expected

    3. Perl modules returns the response of the webservice to the main program

    4. Having two versions of a perl is a work around and later we upgrade it into higher version

    5. Working on windows platform

Not finding
2 direct replies — Read more / Contribute
by dirtdog
on Apr 07, 2020 at 12:47

    Hi Monks, I'm stumped as to why the module is not being found even though i see it in the Oracle perl package version v5.22.0>ls -ltr -rwxr-xr-x 1 oracle dba 1488 May 12 2016 is in my PERL5LIB dir and when i run perl -V i see the following dirs:

    /.../oracle/product/ .../oracle/product/ .../oracle/product/ .../oracle/product/ .../oracle/product/ .../oracle/product/

    yet i get this error:

    Can't locate in @INC (you may need to install the NDBM_File module) (@INC contains: /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ /.../oracle/product/ .). BEGIN failed--compilation aborted.

    Perms are ok so it's definitely not that.

    Any help would be greatly appreciated!


Connecting to remove server with Rex using .pem file
1 direct reply — Read more / Contribute
by nysus
on Apr 07, 2020 at 10:25

    I'm stumped trying to figure out how to use Rex to log into a remote server. The server provides me with a .pem file. I have successfully used this file to log in manually using ssh -i PEM_FILE_NAME blah@

    I tried converting it to public key with ssh-keygen -y -f PEM_FILE_NAME > public.key and have the following in my RexFile:

    Rex::connect( server => '', user => 'my_user_name', public_key => '/home/my_user_name/public.key', );

    But this isn't working. Not sure what else to try. Thanks.

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

Tk Tablematrix set color of selected row
3 direct replies — Read more / Contribute
by Takamoto
on Apr 06, 2020 at 13:00


    This is really a low priority question, but been myself a perfectionist in UI design, I was wondering if there is a possibility to set the color Tablematrix uses when a cell/row is selected/in focus/highlighted (I do not know how to express it, sorry). Standard is a a quite old fashioned blue. I tried with $t->tagRow('active',$row); but this is actually not the right way. I can see the selection going blue and then getting the set color (not to mention that I have not implemented the way to reset the original color when another row is selected.

    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = "$row,$col"; } } print "Creating Table...\n"; sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } sub rowSub{ my $row = shift; return "Oddrow" if( $row > 0 && $row%2) ; } my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 6, -height => 6, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&coloring, -colstretchmode => 'last', -rowtagcommand => \&rowSub, -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se', -relief => 'ridge', -selectmode => 'extended', -selecttype=>'row', ); # Color definitions here: $t->tagConfigure('active', -bg => 'lightyellow', -fg => 'red', -relief + => 'sunken'); $t->pack(-expand => 1, -fill => 'both'); $t->focus; $t->configure (-state=>'disabled'); Tk::MainLoop; sub coloring { print "COLORING SELECTED ROW...\n"; my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; $t->tagRow('active',$row); }
Lost in compressed encodings
4 direct replies — Read more / Contribute
by Skeeve
on Apr 06, 2020 at 04:22

    This is a follow up of my Lost in encodings question.

    Thanks to the answers given there I was able to solve that issue, but now I'm clueless again as I now need to read in compressed (gzip) UTF-8 files and I do not know how to convince perl to read them as UTF-8.

    My code for opening the files is:

    open my $in, '<:utf8', $filename or die "Can't read $filename: $!\ +n"; if ($filename=~/\.gz$/) { $in= new IO::Uncompress::Gunzip $in, { AutoClose => 1 }; }

    When reading uncompressed data, it works fine as I could verify with the help given in my previous thread. I did so by setting the debugger to UTF-8. When reading uncompressed data the Umlaut "" is correctly displayed as "". When reading the same data from a compressed file the "" is displayed as "ü".

    I have no idea how to make perl consider the compressed data as UTF-8?


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

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (6)
    As of 2020-04-08 18:44 GMT
    Find Nodes?
      Voting Booth?
      The most amusing oxymoron is:

      Results (45 votes). Check out past polls.