Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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
problem setting up CPAN Tester reporter on strawberry perl -- CPAN::Reporter
1 direct reply — Read more / Contribute
by Discipulus
on Feb 14, 2019 at 06:51
    Hello monks,

    I'm really need some guidance in setting up a cpan tester framework within my strawberry distributions. Even if I finally ended with something usable I have a lots of doubts and things does not run smoothly as they used to be with my strawberry perl instances.

    I've followed the manual at cpanwiki - quickstart (following numbered steps refer to the guide)

    Three different options are given: cpan classic tool, cpanp and cpanm and I choosed the first because it's the basic tool that must run and because of some other reasons.

    I use normally strawberry portable editions, so I downloaded a fresh copy of strawberry-perl-5.28.1.1-64bit-portable and extracted to c:\SCRIPTS and to play as nice as possible I cleaned PATH a bit: PATH=C:\SCRIPTS\perl5.28-64bit\perl\site\bin;C:\SCRIPTS\perl5.28-64bit\perl\bin;C:\SCRIPTS\perl5.28-64bit\c\bin;C:\Windows\system32;C:\Windows

    Ok, let's follow the above mentioned guide:

    step 1

    cpan> install Task::CPAN::Reporter # a lot of output, but relevant parts are: Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Config\Tiny.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Devel\Autoflush.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Test\Reporter.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Test\Reporter\Trans +port.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Test\Reporter\Trans +port\File.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Test\Reporter\Trans +port\Null.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter\API.p +m Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter\Confi +g.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter\FAQ.p +m Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter\Histo +ry.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Reporter\Prere +qCheck.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Data\UUID.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Data\GUID.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\IO\Prompt\Tiny.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Fact.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Report.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource.p +m Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Fact\Hash. +pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Fact\Strin +g.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\c +pan.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\m +etabase.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\p +erl.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\c +pan\distfile.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\m +etabase\fact.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\m +etabase\user.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Resource\p +erl\commit.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\User\Email +Address.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\User\FullN +ame.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\User\Profi +le.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\User\Secre +t.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Report +.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\I +nstalledModules.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\L +egacyReport.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\P +erlConfig.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\P +rereqs.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\T +estEnvironment.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\T +esterComment.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\T +estOutput.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\CPAN\Testers\Fact\T +estSummary.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Metabase\Client\Sim +ple.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Test\Reporter\Trans +port\Metabase.pm Installing C:\SCRIPTS\perl5.28-64bit\perl\site\lib\Task\CPAN\Reporter. +pm Appending installation info to C:\SCRIPTS\perl5.28-64bit\perl\lib/perl +local.pod DAGOLDEN/Task-CPAN-Reporter-0.003.tar.gz C:\SCRIPTS\perl5.28-64bit\c\bin\gmake.exe install UNINST=1 -- OK

    step 2

    C:\SCRIPTS\perl5.28-64bit>metabase-profile Enter full name: lorenzo Enter email address: lorenzo@cpan.org Enter password/secret: ********* Writing profile to 'metabase_id.json'

    step 3

    C:\SCRIPTS\perl5.28-64bit> mkdir %HOMEDRIVE%%HOMEPATH%\.cpantesters C:\SCRIPTS\perl5.28-64bit> copy metabase_id.json %HOMEDRIVE%%HOMEPATH% +\.cpantesters 1 file copied.

    step 4 (Note: the only non default answer i gave was the first: I want to send reports! I searched the FAQ about it but found nothing. Also note that I specified the mail address in a wrong way and caused the Name not appearing: a bit more check will be good though.. or two fields: display name and mail address )

    cpan> o conf init test_report ... <test_report> Generate test reports if CPAN::Reporter is installed (yes/no)? [no] ye +s Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 1. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 1. Would you like me configure CPAN::Reporter now? [yes] Proceeding to configure CPAN::Reporter. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 2. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 2. ... CPAN::Reporter: no config file found; creating a new one. CPAN::Reporter requires a valid email address to identify senders in the body of a test report. Please use a standard email format like: "John Doe" <jdoe@example.com> email_from? [] lorenzo@cpan.org ... (Recommended: 'default:ask/no pass/na:no') edit_report? [default:ask/no pass/na:no] ... (Recommended: 'default:ask/yes pass/na:yes') send_report? [default:ask/yes pass/na:yes] ... (Recommended: 'Metabase uri https://metabase.cpantesters.org/api/v1/ i +d_file metabase_id.json') transport? [Metabase uri https://metabase.cpantesters.org/api/v1/ id_f +ile metabase_id.json] Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 6. Would you like to run 'metabase-profile' now to create 'C:\SCRIPTS\per +l5.28-64bit\data\.cpanreporter\metabase_id.json'? [y] Running [C:\SCRIPTS\PERL5~1.28-\perl\site\bin\metabase-profile.BAT --o +utput C:\SCRIPTS\perl5.28-64bit\data\.cpanreporter \metabase_id.json --email lorenzo@cpan.org --secret ********]... Enter full name: Writing profile to 'C:\SCRIPTS\perl5.28-64bit\data\.cpanreporter\metab +ase_id.json' CPAN::Reporter: writing config file to 'C:\SCRIPTS\perl5.28-64bit\data +\.cpanreporter\config.ini'. Returning to CPAN configuration. commit: wrote 'C:\SCRIPTS\perl5.28-64bit\perl\lib/CPAN/Config.pm' cpan> cpan> cpan> cpan> o conf commit commit: wrote 'C:\SCRIPTS\perl5.28-64bit\perl\lib/CPAN/Config.pm' cpan>

    doubt 1

    What happened? Was the metabase_id.json created another time? Which one will be used? That I created in step 2 and copied in step 3 or that created in step 4 at C:\SCRIPTS\perl5.28-64bit\data\.cpanreporter\metabase_id.json ??

    doubt 2

    where all these errors comes from (see the above output)?

    Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157, <STDIN> line 1.

    step 5 Let's try!

    cpan> test Win32::File Database was generated on Mon, 11 Feb 2019 20:25:05 GMT Running test for module 'Win32::File' Fetching with LWP: http://cpan.strawberryperl.com/authors/id/J/JD/JDB/Win32-File-0.07.tar +.gz Fetching with LWP: http://cpan.strawberryperl.com/authors/id/J/JD/JDB/CHECKSUMS Checksum for C:\SCRIPTS\perl5.28-64bit\cpan\sources\authors\id\J\JD\JD +B\Win32-File-0.07.tar.gz ok Scanning cache C:\SCRIPTS\perl5.28-64bit\cpan\build for sizes ...................................................................... +......DONE Configuring J/JD/JDB/Win32-File-0.07.tar.gz with Makefile.PL Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Checking if your kit is complete... Looks good Generating a gmake-style Makefile Writing Makefile for Win32::File Writing MYMETA.yml and MYMETA.json (C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe Makefile.PL exited with 0 +) CPAN::Reporter: Makefile.PL result is 'pass', No errors. JDB/Win32-File-0.07.tar.gz C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe Makefile.PL -- OK Running make for J/JD/JDB/Win32-File-0.07.tar.gz Subroutine JSON::PP::Boolean::(++ redefined at C:\SCRIPTS\perl5.28-64b +it\perl\lib/overload.pm line 48. Subroutine JSON::PP::Boolean::(0+ redefined at C:\SCRIPTS\perl5.28-64b +it\perl\lib/overload.pm line 48. Subroutine JSON::PP::Boolean::(-- redefined at C:\SCRIPTS\perl5.28-64b +it\perl\lib/overload.pm line 48. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. cp File.pm blib\lib\Win32\File.pm Running Mkbootstrap for File () "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Command -e c +hmod -- 644 "File.bs" "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Command::MM +-e cp_nonempty -- File.bs blib\arch\auto\Win32\Fil e\File.bs 644 "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" "C:\SCRIPTS\perl5.28-64b +it\perl\lib\ExtUtils/xsubpp" -typemap C:\SCRIPTS\ perl5.28-64bit\perl\lib\ExtUtils\typemap -typemap C:\SCRIPTS\perl5.28- +64bit\cpan\build\Win32-File-0.07-0\typemap File.x s > File.xsc "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Command -e m +v -- File.xsc File.c gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDI +O -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bit +fields -s -O2 -DVERSION=\"0.07\" -DXS_VERSION=\" 0.07\" "-IC:\SCRIPTS\perl5.28-64bit\perl\lib\CORE" File.c "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Mksymlists \ -e "Mksymlists('NAME'=>\"Win32::File\", 'DLBASE' => 'File', 'DL_F +UNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { } , 'DL_VARS' => []);" g++.exe File.def -o blib\arch\auto\Win32\File\File.xs.dll -mdll -s -L" +C:\SCRIPTS\perl5.28-64bit\perl\lib\CORE" -L"C:\SCR IPTS\perl5.28-64bit\c\lib" File.o "C:\SCRIPTS\perl5.28-64bit\perl\li +b\CORE\libperl528.a" -lmoldname -lkernel32 -luser3 2 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut3 +2 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversi on -lodbc32 -lodbccp32 -lcomctl32 -Wl,--enable-auto-image-base "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Command -e c +hmod -- 755 blib\arch\auto\Win32\File\File.xs.dll (C:\SCRIPTS\perl5.28-64bit\c\bin\gmake.exe exited with 0) CPAN::Reporter: gmake result is 'pass', No errors. JDB/Win32-File-0.07.tar.gz C:\SCRIPTS\perl5.28-64bit\c\bin\gmake.exe -- OK Running make test Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" -MExtUtils::Command::MM +-e cp_nonempty -- File.bs blib\arch\auto\Win32\Fil e\File.bs 644 "C:\SCRIPTS\perl5.28-64bit\perl\bin\perl.exe" "-MExtUtils::Command::MM +" "-MTest::Harness" "-e" "undef *Test::Harness::Sw itches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t t/file.t .. ok All tests successful. Files=1, Tests=5, 1 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU +) Result: PASS (C:\SCRIPTS\perl5.28-64bit\c\bin\gmake.exe test exited with 0) CPAN::Reporter: Test result is 'pass', All tests successful. CPAN::Reporter: preparing a CPAN Testers report for Win32-File-0.07 Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. CPAN::Reporter: sending test report with 'pass' via Metabase Use of uninitialized value $_[0] in string eq at C:/SCRIPTS/perl5.28-6 +4bit/perl/lib/File/Spec/Win32.pm line 157. JDB/Win32-File-0.07.tar.gz C:\SCRIPTS\perl5.28-64bit\c\bin\gmake.exe test -- OK cpan>

    doubt 3

    I defeinitively messed my cpan? ;(

    doubt 4

    I go to http://metabase.cpantesters.org/tail/log.txt to see which profile was used (steps 2,3 or step 4 one?) and I see:

    [2019-02-11T21:02:29Z] [] [pass] [JDB/Win32-File-0.07.tar.gz] [MSWin32 +-x64-multi-thread] [perl-v5.28.1] [1b296cef-6c08-1014-b6df-cd4687d894 +94] [2019-02-11T21:02:29Z]

    No lorenzo name in square brackets is shown.. so I presume that in step 4 was used: infact the other has the name present but there is not in that created in step 4

    After some hours I found two entries in the matrix:

    They both are mine.. they both have no name displayed..

    others doubts

    It's acceptable the above situation? I made some gross, coarse errors? It's the documentation erroneous? It's some of the used modules bugged under windows and this is the cause of all that File::Spec::Win32 errors?

    Tests are useful, no? If so I'd expect the testing reporting framework setup to be reliable on all platforms or I'm wrong?

    Generally spekking: which is the mechanism involved? what is the role of the metabase_id.json file? And what about the other file generated in step 4 (now I'm sure there are used these: I see the reports-sent.db populated)?

    Directory di C:\SCRIPTS\perl5.28-64bit\data\.cpanreporter 11/02/2019 21:57 199 config.ini 11/02/2019 21:57 1.871 metabase_id.json 11/02/2019 22:02 119 reports-sent.db

    Can I modify them (for example to include my name)? How? I must copy them if I want to use the same infos for other perl instance?

    I'd really wanna help but who can help me?

    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.
LWP::Useragent doesn't work on certain HTTPS websites?
2 direct replies — Read more / Contribute
by sectokia
on Feb 14, 2019 at 06:37

    Hi wise monks, I have found that simple LWP get on HTTPS doesn't always work. Below is example on a server which it never seems to work on:

    use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ); my $res = $ua->get('https://www.target.com.au/'); print $res->content;

    The error I get is:

    Status read failed: Connection reset by peer at /usr/share/perl5/Net/H +TTP/Methods.pm line 282.
    I had a look at that file and its over my head. Any ideas? Thanks!

Gtk3 and CSS styles
1 direct reply — Read more / Contribute
by Anonymous Monk
on Feb 13, 2019 at 10:31

    In Gtk2, I could apply a style to various widgets using RC strings. Under Gtk3, it's necessary to use CSS styles.

    I can't find any working examples of the new Perl code, besides one from 2012 which no longer works. (The site won't let me post the link.)

    I am able to apply a CSS style to a whole window, using the script below. But applying the style to a single widget (in this case, a Gtk3::TextView) does not work, and I can't see why it's wrong.

    #!/usr/bin/perl use strict; use diagnostics; use warnings; #use Glib qw(TRUE FALSE); use Gtk3 '-init'; # Set up CSS style my $provider = Gtk3::CssProvider->new(); # Why are these lines necessary? What function do they serve? my $display = Gtk3::Gdk::Display::get_default; my $screen = Gtk3::Gdk::Display::get_default_screen($display); Gtk3::StyleContext::add_provider_for_screen($screen, $provider, 600); # This applies the style to the whole window #my $theming = "* {\nbackground-color: #000000;\ncolor: #FF0000;\n}"; #$provider->load_from_data($theming, -1, undef); # But this doesn't apply the style (just) to the textview my $theming = "GtkTextView {\nbackground-color: #000000;\ncolor: #FF00 +00;\n}"; $provider->load_from_data($theming, -1, undef); # Open a Gtk3 window containing a Gtk3::TextView my $window = Gtk3::Window->new('toplevel'); $window->set_title('Hello world'); $window->set_position('center'); $window->set_default_size(600, 400); $window->signal_connect('delete-event' => sub { Gtk3->main_quit(); exit; }); my $scrollWin = Gtk3::ScrolledWindow->new(undef, undef); $window->add($scrollWin); my $textView = Gtk3::TextView->new; $scrollWin->add_with_viewport($textView); $textView->get_buffer()->set_text("Hello, world!"); $window->show_all(); # Start Gtk3's main loop Gtk3->main();
Adding text file data to hashes and array
4 direct replies — Read more / Contribute
by Tigor
on Feb 13, 2019 at 05:38

    I have a text file which contains fruits data which get sold every month as below

    file name is fruits.txt

    the text file data looks like as below.Please  get average of the values stored in array as well.I have tried harder to get the ouput but stuck.
    Fruit Jan feb mar apr Apple 40 45 50 54 orange 12 25 24 29 Pineapple 10 20 30 40

    I want output as below

    {apple => [40,45,50,54] Orange =>[12,25,24,29]}

    i have written a code for the above desired ouput.Please find my code below

    use strict; use warnings; my $filename = 'fruits.txt'; #opening the text file open(DATA, '<', $filename) or die "Could not open file '$filename' $!"; readline(DATA);#skipping the header my %data; while (<DATA>) { my @fields = split; my $key = join(' ', splice(@fields, 0, 2)); $data{$key} = \@fields; } for my $key (sort(keys(%data))) { printf("%s=> %s\n", $key, join(' ', @{$data{$key}})); }
On the road again with Gtk2 and PAR::Packer
4 direct replies — Read more / Contribute
by frazap
on Feb 13, 2019 at 03:00
    Background:

    Some years ago I succeed in having Gtk2 script packed with PAR after including dll with --link option.

    These were Glib.dll, Gtk2.dll, Cairo.dll, Pango.dll.

    The trick that was working then was to include the above dll and to rename the the Glib, Gtk2, Pango folders in lib/auto to hide them from the search path.

    The dll were then taken from the par archive at shlib\MSWin32-x86-multi-thread-64int\ folder and the exe works.

    More details here https://www.mail-archive.com/par@perl.org/msg05033.html

    The problem:

    I did a new perl install (strawberry perl v. 5.24) when my OS was changed. I compile the Gtk2 from source.

    I can't find these dll (Glib.dll, Gtk2.dll) in my new perl install, I have instead Glib.xs.dll, Gtk2.xs.dll etc. I did find the first group in my tmp folders under C:/Users... where par archives are extracted: I have copied these dll in c:/docs/perl_dll

    I tried to pack the following script
    use strict; use warnings; use Gtk2 '-init'; use Glib qw/TRUE FALSE/; my $window = Gtk2::Window->new; $window->signal_connect (destroy => sub { Gtk2->main_quit; }); $window->show_all(); Gtk2->main;

    Using Shawn Laffan's pp_autolink.pl https://github.com/shawnlaffan/perl-pp-autolink or the -x option of pp without any dll included make an exe that crash

    Can't load 'C:\Users\rappazf\AppData\Local\Temp\par-...\778ce824.xs.dl +l' for module Pango: load_file:The specified module could not be found at + C:/strawberry/perl/lib/DynaLoader.pm line 193.
    Running
    objdump -x 778ce824.xs.dll | grep "DLL Name" gives DLL Name: libcairo-2.dll DLL Name: libglib-2.0-0.dll DLL Name: libgobject-2.0-0.dll DLL Name: libpango-1.0-0.dll DLL Name: libpangocairo-1.0-0.dll DLL Name: msvcrt.dll DLL Name: Cairo.xs.dll DLL Name: Glib.xs.dll DLL Name: KERNEL32.dll DLL Name: perl524.dll
    Adding the xs.dll with --link did change the errors, but the inclusion of the 4 xs.dll does not give a working exe.

    With these dll on the option for pp

    -l 'C:/strawberry/perl/site/lib/auto/Cairo/Cairo.xs.dll' -l 'C:/strawberry/perl/site/lib/auto/Glib/Glib.xs.dll' -l 'C:/strawberry/perl/site/lib/auto/Gtk2/Gtk2.xs.dll' -l 'C:/strawberry/perl/site/lib/auto/Pango/Pango.xs.dll' -l 'C:\docs\perl_dll\Pango.dll' -l 'C:\docs\perl_dll\Glib.dll' -l 'C:\docs\perl_dll\Gtk2.dll' -l 'C:\docs\perl_dll\Cairo.dll'
    Without hidding the lib/auto/Glib .../Gtk2 .../Pango I get the error
    GLib-GObject-CRITICAL **: g_boxed_type_register_static: assertion `g_t +ype_from_name (name) == 0' failed at C:/strawberry/perl/lib/DynaLoade +r.pm line 210. cannot register alias Gtk2::Pango::Attribute for the unregistered type + (null) at C:/strawberry/perl/lib/DynaLoader.pm line 210. Compilation failed in require at script/simple.pl line 12. BEGIN failed--compilation aborted at script/simple.pl line 12.
    Renaming these folder and adding the dll above still gives the error below
    Can't locate loadable object for module Glib in @INC (@INC contains: C +:\Users\rappazf\AppData\Local\Temp\par-72617070617a66\cache-6d3232558 +24cd4b77983f4c61ece5aa2d701ac21\inc\lib C:\Users\rappazf\AppData\Loca +l\Temp\par-72617070617a66\cache-6d323255824cd4b77983f4c61ece5aa2d701a +c21\inc CODE(0x31e7e8c) CODE(0x31e8084)) at C:/strawberry/perl/site/l +ib/PAR/Heavy.pm line 99. Compilation failed in require at Gtk2.pm line 30. That's were 'use Gib +;' is called in Gtk2.pm and adding the Glib.dll, Gtk2.dll from the pe +rl_dll folder does not change this.

    Can someone explains the difference between Glib.dll and Glib.xs.dll ? How come the first group is missing from my perl tree and my scripts are still working ?

    How can I packed this script ?

    François

File::Temp throwing errors after installation of a module
1 direct reply — Read more / Contribute
by Anonymous Monk
on Feb 12, 2019 at 16:29

    Hello, we would like to request for some assistance with an issue with File::Temp that we've experienced since installing a new module: https://metacpan.org/pod/Net::Amazon::S3#new

    After installation of the module & its dependencies, we had received errors from Temp::File stating:

    Your vendor has not defined Fcntl macro O_NOINHERIT, used at /usr/shar +e/perl5/File/Temp.pm line 247. Your vendor has not defined Fcntl macro O_EXLOCK, used at /usr/share/p +erl5/File/Temp.pm line 256. Your vendor has not defined Fcntl macro O_TEMPORARY, used at /usr/shar +e/perl5/File/Temp.pm line 277. Your vendor has not defined Fcntl macro O_EXLOCK, used at /usr/share/p +erl5/File/Temp.pm line 255.

    Upon checking File::Temp these are the lines that are apparently causing issues

    my $OPENFLAGS = O_CREAT | O_EXCL | O_RDWR; my $LOCKFLAG; unless ($^O eq 'MacOS') { for my $oflag (qw/ NOFOLLOW BINARY LARGEFILE NOINHERIT /) { my ($bit, $func) = (0, "Fcntl::O_" . $oflag); no strict 'refs'; $OPENFLAGS |= $bit if eval { # Make sure that redefined die handlers do not cause problems # e.g. CGI::Carp local $SIG{__DIE__} = sub {}; local $SIG{__WARN__} = sub {}; $bit = &$func(); 1; }; } # Special case O_EXLOCK $LOCKFLAG = eval { local $SIG{__DIE__} = sub {}; local $SIG{__WARN__} = sub {}; &Fcntl::O_EXLOCK(); }; }

    we've tried applying the fix mentioned here, but it did not work.

    https://bugzilla.mozilla.org/show_bug.cgi?id=171674 https://bugzilla.mozilla.org/show_bug.cgi?id=179171

    For reference heres the code after applying the fix:

    $OPENFLAGS |= $bit if eval { # Make sure that redefined die handlers do not cause problems # e.g. CGI::Carp local $SIG{__DIE__} = sub {}; local $SIG{__WARN__} = sub {}; local *CORE::GLOBAL::die = sub {}; $bit = &$func(); 1; };

    At this point we are completely lost, is there anything else we can try to remedy the issue? Thanks in advance.

Building Good Modules
5 direct replies — Read more / Contribute
by John N8UR
on Feb 12, 2019 at 16:12
    I've created a handful of modules that each contain one fairly complex function (maybe a couple of hundred lines of code). They are all wrappers to manage and convert PostScript files. For maintainability, I'd like to keep each one in its own file. I would like to know the proper way to manage this, assuming I might want to share these on CPAN. I'm using the "module-starter" tool to create the framework.

    I see three options:

    • Make each function its own standalone module, so I'd create PostScript::PSjoin, PostScript::PS2png, and PostScript::PStopdf as three standalone projects.
    • Keep three separate .pm files, but put them in the same directory structure under one PostScript::MyTools or somesuch. If I do that, are there things required to properly build the dist?
    • Put all three functions in one big file. This is my least favorite option.

    I'd like any guidance on this so I do the right thing.

    Thanks!

Fusion 360 API module?
1 direct reply — Read more / Contribute
by BernieC
on Feb 12, 2019 at 14:57
    The CAD program from Autodesk, Fusion 360, has an API of some kind. I haven't found docs about it yet but it has a Python implementation. Anyone know if there's a Perl module for talking to F360?
regex compilation
2 direct replies — Read more / Contribute
by morgon
on Feb 12, 2019 at 12:33
    Hi

    could someone please explain this behaviour to me as it is unexpected for me:

    my $regex1 = qr/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my $regex2 = qq/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my ($match1) = q|"hubba \"bubba\""| =~ $regex1; my ($match2) = q|"hubba \"bubba\""| =~ /$regex2/; print "$match1\n$match2\n"; __END__ output: hubba \"bubba\" hubba \
    In the first case I compile a regex immediately, in the second I define a string and only in the line where I match it get's compiled.

    I would have expected that the result would be the same - but it isn't...

    Why?

    Many thanks!

How can I access package variables in a dynamic way
4 direct replies — Read more / Contribute
by bangor
on Feb 12, 2019 at 10:23
    I have some variables in a package like this:
    package Person; our $address_1; our $address_2; our $address_3;
    In my script I want to do something like
    my @lines; foreach my $num (1..3) { push(@lines, $Person::address_$num); }
    Obviously that doesn't work. I can't change the Person package right now.
    Thanks for any help.

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.
  • 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 drinking their drinks and smoking their pipes about the Monastery: (4)
    As of 2019-02-16 09:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I use postfix dereferencing ...









      Results (95 votes). Check out past polls.

      Notices?