Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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
(Solved) Extracting sometimes null string from text variable
2 direct replies — Read more / Contribute
by Marshall
on Sep 17, 2017 at 14:24
    I am parsing a $text variable from which I want to extract a Club name.
    I have a solution that "works" as shown below.
    I have been unable to do this in a single regex which handles both of my cases. So I just used 3 statements. This is a pragmatic "do what works" situation and is fine as far as that goes. However, in the search for elegance, I suspect that a single regex could be constructed that handles both cases?

    In case2, there is a new line right after Club:. My attempts at a single regex often wind up capturing Comments: instead of a null string for Club name. Ideas welcome.

    #!/usr/bin/perl use strict; use warnings; my $case1 = "Club: Some Club Comments: "; my $case2 = "Club: Comments: "; foreach my $text ($case1, $case2) { # extract Club name (my $club) = $text =~ /Club:(.*)/; # need to allow for blank Club + name $club =~ s/^\s*//; $club =~ s/\s*$//; print "line before name\n"; # print out to make sure $club doesn' +t have a \n print "extracted Club name: '$club'\n"; print "line after name\n"; } __END__ line before name extracted Club name: 'Some Club' line after name line before name extracted Club name: '' line after name ======== I've tried things like: /Club:\s*(.*)[ ]*\n/ and various other encantations, but that picks up 'Comments:' intead of a blank Club name line before name extracted Club name: 'Some Club' line after name line before name extracted Club name: 'Comments:' line after name
    Update:
    LanX and Anonymous Monk came up with the ball!
    I hadn't seen \h before, but it works here!
    #!/usr/bin/perl use strict; use warnings; my $case1 = "Club: Some Club Comments: "; my $case2 = "Club: Comments: "; foreach my $text ($case1, $case2) { # extract Club name (my $club) = $text =~ /Club:\h*(.*?)\h*\n/; # need to allow for b +lank Club name print "line before name\n"; # print out to make sure $club doesn' +t have a \n print "extracted Club name: '$club'\n"; print "line after name\n"; } __END__ line before name extracted Club name: 'Some Club' line after name line before name extracted Club name: '' line after name
Unscalar'ize a fake array
5 direct replies — Read more / Contribute
by Gtforce
on Sep 17, 2017 at 08:29

    I receive an array @result, which is my starting point. I think it is an array, but when I run this snippet of code to test the data that is in the array, it would appear that there's a scalar sitting in it. My end-purpose is to calculate the average of the last column, but can't figure out how. Any help is appreciated, thanks.

    my $counter=0; foreach my $element (@result) { print "\nCHECKPOINT\n $result[$counter]\n"; $counter ++; }

    Result:

    CHECKPOINT

    2017-08-01 20MICRONS 37744

    2016-08-01 20MICRONS 25966

    2016-04-20 20MICRONS 30807

    2016-04-01 20MICRONS 32780

tkpp fails at very end
3 direct replies — Read more / Contribute
by smh
on Sep 17, 2017 at 01:07

    I am running tkpp to convert my perl script to an "exe" file. my environment is ASP perl 64 bit V5.24 and I have installed "PAR-Packer-1.037". The script I am trying to convert, had no issues when I was using ASP PDK v9.2. Now every thing seems to work find except the end with the following error message at the veru last line in the log file.

    C:\Perl64\site\bin\pp.bat: Failed to extract a parl from 'PAR::Strippe +dPARL::Static' to file 'C:\Users\Shahriar\AppData\Local\Temp\parlGiqe +nzz.exe'Building Q:\W_PERL\_000_Dev\Netlister\Netlister.exe failed : The system cannot find the file specified.
cannot gmake Math-Random Random.xs.dll
1 direct reply — Read more / Contribute
by BobbyT420
on Sep 16, 2017 at 14:01

    I'm hella Perl n00b so please be gentle...afterall, I've never done this before. I cannot get Math-Random to install. I have tried cpanm (with and without force) and have also tried manually from the tarball. MakeMaker is installed and up to date which seems to be it's only dependency based on the makefile. The module install is failing to make the Random.xs.dll file. Someone has asked the monks a similar question here (http://www.perlmonks.org/?node_id=1001132) but their solution does not work for me. AutoInstall:

    cpanm Math::Random --> Working on Math::Random Fetching http://www.cpan.org/authors/id/G/GR/GROMMEL/Math-Random-0.72. +tar.gz ... OK Configuring Math-Random-0.72 ... OK Building and testing Math-Random-0.72 ... FAIL

    The log file for the autobuild is:

    cpanm (App::cpanminus) 1.7043 on perl 5.026000 built for MSWin32-x64-m +ulti-thread Work directory is C:\Users\BOBTEW~1/.cpanm/work/1505582396.6584 You have make D:\Strawberry\c\bin\gmake.exe You have LWP 6.26 Falling back to Archive::Tar 2.26 You have C:\Rtools\bin\unzip.exe Searching Math::Random () on cpanmetadb ... --> Working on Math::Random Fetching http://www.cpan.org/authors/id/G/GR/GROMMEL/Math-Random-0.72. +tar.gz -> OK Unpacking Math-Random-0.72.tar.gz Entering Math-Random-0.72 Checking configure dependencies from META.yml Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.30) Configuring Math-Random-0.72 Running Makefile.PL Checking if your kit is complete... Looks good Generating a gmake-style Makefile Writing Makefile for Math::Random Writing MYMETA.yml and MYMETA.json -> OK Checking dependencies from MYMETA.json ... Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.30) Building and testing Math-Random-0.72 cp test2.pl blib\lib\Math\test2.pl cp example.pl blib\lib\Math\example.pl cp test1.pl blib\lib\Math\test1.pl cp Random.pm blib\lib\Math\Random.pm AutoSplitting blib\lib\Math\Random.pm (blib\lib\auto\Math\Random) Running Mkbootstrap for Random () "D:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 +"Random.bs" "D:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonemp +ty -- Random.bs blib\arch\auto\Math\Random\Random.bs 644 "D:\Strawberry\perl\bin\perl.exe" "D:\Strawberry\perl\lib\ExtUtils/xsu +bpp" -typemap D:\STRAWB~1\perl\lib\ExtUtils\typemap Random.xs > Ran +dom.xsc "D:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e mv -- Random. +xsc Random.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-bitfields -s -O2 -D +VERSION=\"0.72\" -DXS_VERSION=\"0.72\" "-ID:\STRAWB~1\perl\lib\CORE" + Random.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-bitfields -s -O2 -D +VERSION=\"0.72\" -DXS_VERSION=\"0.72\" "-ID:\STRAWB~1\perl\lib\CORE" + com.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-bitfields -s -O2 -D +VERSION=\"0.72\" -DXS_VERSION=\"0.72\" "-ID:\STRAWB~1\perl\lib\CORE" + helper.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-bitfields -s -O2 -D +VERSION=\"0.72\" -DXS_VERSION=\"0.72\" "-ID:\STRAWB~1\perl\lib\CORE" + linpack.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-bitfields -s -O2 -D +VERSION=\"0.72\" -DXS_VERSION=\"0.72\" "-ID:\STRAWB~1\perl\lib\CORE" + randlib.c "D:\Strawberry\perl\bin\perl.exe" -MExtUtils::Mksymlists \ -e "Mksymlists('NAME'=>\"Math::Random\", 'DLBASE' => 'Random', 'D +L_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => [ +]);" g++ Random.def -o blib\arch\auto\Math\Random\Random.xs.dll -mdll -s -L +"D:\STRAWB~1\perl\lib\CORE" -L"D:\STRAWB~1\c\lib" Random.o com.o help +er.o linpack.o randlib.o "D:\STRAWB~1\perl\lib\CORE\libperl526.a" " +D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libm.a" "D:\STRAWB~1\c\x86_64-w6 +4-mingw32\lib\libmoldname.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\li +bkernel32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libuser32.a" "D:\S +TRAWB~1\c\x86_64-w64-mingw32\lib\libgdi32.a" "D:\STRAWB~1\c\x86_64-w6 +4-mingw32\lib\libwinspool.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\li +bcomdlg32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libadvapi32.a" "D: +\STRAWB~1\c\x86_64-w64-mingw32\lib\libshell32.a" "D:\STRAWB~1\c\x86_6 +4-w64-mingw32\lib\libole32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\l +iboleaut32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libnetapi32.a" "D +:\STRAWB~1\c\x86_64-w64-mingw32\lib\libuuid.a" "D:\STRAWB~1\c\x86_64- +w64-mingw32\lib\libws2_32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\li +bmpr.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libwinmm.a" "D:\STRAWB~ +1\c\x86_64-w64-mingw32\lib\libversion.a" "D:\STRAWB~1\c\x86_64-w64-mi +ngw32\lib\libodbc32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libodbcc +p32.a" "D:\STRAWB~1\c\x86_64-w64-mingw32\lib\libcomctl32.a" -Wl,--ena +ble-auto-image-base Random.o:Random.c:(.text+0x9): undefined reference to `_imp__Perl_get_ +context' Random.o:Random.c:(.text+0x75): undefined reference to `_imp__Perl_sv_ +2iv_flags' Random.o:Random.c:(.text+0x8d): undefined reference to `_imp__Perl_sv_ +newmortal' Random.o:Random.c:(.text+0x115): undefined reference to `_imp__Perl_sv +_setnv_mg' Random.o:Random.c:(.text+0x144): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x159): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x1be): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x1fa): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x251): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x268): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x2cd): undefined reference to `_imp__Perl_sv +_2pv_flags' Random.o:Random.c:(.text+0x30f): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x329): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x398): undefined reference to `_imp__Perl_st +ack_grow' Random.o:Random.c:(.text+0x3a9): undefined reference to `_imp__Perl_ne +wSViv' Random.o:Random.c:(.text+0x3c9): undefined reference to `_imp__Perl_sv +_2mortal' Random.o:Random.c:(.text+0x42a): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x439): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x4ae): undefined reference to `_imp__Perl_sv +_2pv_flags' Random.o:Random.c:(.text+0x4f5): undefined reference to `_imp__Perl_st +ack_grow' Random.o:Random.c:(.text+0x506): undefined reference to `_imp__Perl_ne +wSViv' Random.o:Random.c:(.text+0x526): undefined reference to `_imp__Perl_sv +_2mortal' Random.o:Random.c:(.text+0x5a2): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x5b9): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x625): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x663): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0x67d): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0x71d): undefined reference to `_imp__Perl_sv +_setiv_mg' Random.o:Random.c:(.text+0x764): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x779): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x7e5): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x823): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0x83d): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0x8dd): undefined reference to `_imp__Perl_sv +_setiv_mg' Random.o:Random.c:(.text+0x924): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0x939): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0x9a5): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x9e3): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0x9fd): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0xaa3): undefined reference to `_imp__Perl_sv +_setiv_mg' Random.o:Random.c:(.text+0xaf4): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0xb09): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0xb75): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0xb8f): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0xc3b): undefined reference to `_imp__Perl_sv +_setiv_mg' Random.o:Random.c:(.text+0xc69): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0xc79): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0xce1): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0xd21): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0xd3b): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0xdc7): undefined reference to `_imp__Perl_sv +_setnv_mg' Random.o:Random.c:(.text+0xe18): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0xe28): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0xe85): undefined reference to `_imp__Perl_sv +_2iv_flags' Random.o:Random.c:(.text+0xec4): undefined reference to `_imp__Perl_cr +oak_xs_usage' Random.o:Random.c:(.text+0xed9): undefined reference to `_imp__Perl_ge +t_context' Random.o:Random.c:(.text+0xf41): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0xf81): undefined reference to `_imp__Perl_sv +_2nv_flags' Random.o:Random.c:(.text+0xf9b): undefined reference to `_imp__Perl_sv +_newmortal' Random.o:Random.c:(.text+0x1027): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x1078): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1089): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x10f1): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1131): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1171): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x118b): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1233): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x12a8): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x12b9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1321): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1361): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x137b): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1407): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x1458): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1469): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x14d5): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x14ed): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x158b): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x15b5): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x15c9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x162e): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x166a): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x16c1): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x16d9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x173e): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x177a): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x17d1): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x17e9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1855): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x186d): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x190b): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x1935): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1949): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x19b5): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x19cd): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1a6b): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x1a95): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1aa9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1aeb): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1b90): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x1ba7): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1bb9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1c25): undefined reference to `_imp__Perl_s +v_2iv_flags' Random.o:Random.c:(.text+0x1c3d): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1cdb): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x1d05): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1d19): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1d81): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1dc1): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1ddb): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x1e67): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x1eb8): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x1ec9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x1f31): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1f71): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x1f8b): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x2017): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x2068): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x2079): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x20e1): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x20fb): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x2186): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x21b8): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x21c9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x2231): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x224b): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x22d6): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x2308): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x2319): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x2381): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x23c1): undefined reference to `_imp__Perl_s +v_2nv_flags' Random.o:Random.c:(.text+0x23db): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x2467): undefined reference to `_imp__Perl_s +v_setnv_mg' Random.o:Random.c:(.text+0x24b8): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x24c9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x250b): undefined reference to `_imp__Perl_s +v_newmortal' Random.o:Random.c:(.text+0x2518): undefined reference to `_imp__Perl_s +eed' Random.o:Random.c:(.text+0x25c0): undefined reference to `_imp__Perl_s +v_setiv_mg' Random.o:Random.c:(.text+0x25d7): undefined reference to `_imp__Perl_c +roak_xs_usage' Random.o:Random.c:(.text+0x25e9): undefined reference to `_imp__Perl_g +et_context' Random.o:Random.c:(.text+0x2614): undefined reference to `_imp__Perl_x +s_handshake' Random.o:Random.c:(.text+0x2622): undefined reference to `_imp__Perl_n +ewXS_deffile' Random.o:Random.c:(.text+0x26c9): undefined reference to `_imp__Perl_n +ewXS_flags' Random.o:Random.c:(.text+0x2932): undefined reference to `_imp__Perl_x +s_boot_epilog' collect2.exe: error: ld returned 1 exit status gmake: *** [Makefile:490: blib\arch\auto\Math\Random\Random.xs.dll] Er +ror 1 -> FAIL Installing Math::Random failed. See C:\Users\BOBTEW~1\.cpanm\w +ork\1505582396.6584\build.log for details. Retry with --force to forc +e install it.

    Manual install with tarball pre-unpacked in ./Strawberry/cpan/build results in the same error as the auto install (see above)

    cd ./Strawberry/cpan/build/Math-Random0.72 perl Makefile.PL gmake

    As per here: http://www.perlmonks.org/?node_id=1001132 ; when I run objdump, the undefined references listed above are listed as so (_imp__Perl_get_context given as an example)

    dmgds00385.o: file format pe-x86-64 SYMBOL TABLE: [ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .tex +t [ 1](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .dat +a [ 2](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .bss [ 3](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .ida +ta$7 [ 4](sec 5)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .ida +ta$5 [ 5](sec 6)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .ida +ta$4 [ 6](sec 7)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000000 .ida +ta$6 [ 7](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 Perl +_get_context [ 8](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __im +p_Perl_get_context [ 9](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 _hea +d____lib_CORE_libperl526_a

    Finally, perl -V outputs

    Summary of my perl5 (revision 5 version 26 subversion 0) configuration +: Platform: osname=MSWin32 osvers=6.3 archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.26.0.2 #1 Sat Sep 2 16:25:32 2017 +x64' config_args='undef' hint=recommended useposix=true d_sigaction=undef useithreads=define usemultiplicity=define use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='gcc' ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANS +I_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLIC +IT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields' optimize='-s -O2' cppflags='-DWIN32' ccversion='' gccversion='7.1.0' gccosandvers='' intsize=4 longsize=4 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long long' ivsize=8 nvtype='double' nvsize=8 Off_t='long long' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='g++' ldflags ='-s -L"D:\STRAWB~1\perl\lib\CORE" -L"D:\STRAWB~1\c\lib"' libpth=D:\STRAWB~1\c\lib D:\STRAWB~1\c\x86_64-w64-mingw32\lib D:\S +TRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0 libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 + -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 - +lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomd +lg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_ +32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc= so=dll useshrplib=true libperl=libperl526.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs dlext=xs.dll d_dlsymun=undef ccdlflags=' ' cccdlflags=' ' lddlflags='-mdll -s -L"D:\STRAWB~1\perl\lib\CORE" -L"D:\STRAWB~1\c +\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Sep 2 2017 16:39:31 @INC: D:/Strawberry/perl/site/lib/MSWin32-x64-multi-thread D:/Strawberry/perl/site/lib D:/Strawberry/perl/vendor/lib D:/Strawberry/perl/lib

    Thanks :)

Regex get Text between two strings with colon
3 direct replies — Read more / Contribute
by MurciaNew
on Sep 16, 2017 at 13:49
    Hi Monks,

    i have a regex problem. I want to get the text between two words with colon (like Example: or Epikrise:)

    I have files (newLine is "\r\n").

    Example of just two files: <<< start file 1>>> Test:\r\n blablabla1\r\n blablablabla2\r\n blablablablabla3\r\n blablablab4\r\n blablablaba5\r\n Test1:\r\n lalala1\r\n lalala2\r\n Hello3:\r\n mymymymy\r\n <<< end file 1>>> <<< start file 2>>> Test:\r\n blablabla1\r\n blablablabla2\r\n blablablablabla3\r\n blablablab4\r\n blablablaba5\r\n blablablaba6\r\n Test3:\r\n lalala1\r\n lalala2\r\n lalala3\r\n City:\r\n Gigi\r\n lulu\r\n Kuku\r\n <<< end file 2>>>

    With a regexp I want to get all text between "Test:" to that next line with a string with ":"(colon) (for the examples "Test2:" for file 1 or "Test3:" for file 2

    as result Test="blablabla1\r\n blablablabla2\r\n blablablablabla3\r\n blablablab4\r\n blablablaba5\r\n"

    or Test="blablabla1\r\n blablablabla2\r\n blablablablabla3\r\n blablablab4\r\n blablablaba5\r\n blablablaba6\r\n" )

    I tried (.+?(\r\n.+){1,}?(?!\w+?:)) but it does not work

    Please help me..... Thanks

    MurciaNew (Guido)

Drawing a Tile using SDLx::Sprite
No replies — Read more | Post response
by Muskovitz
on Sep 16, 2017 at 12:54
    Hello monks!

    i am trying to draw a 2d-tiled map in SDL Perl using the SDLx::Sprite module but i was wondering is this really the proper way to draw a tiled map in SDL Perl? Or there are other ways to do it?
    Here is how i draw a tile in Perl SDL

    my @tile2=map{ my $sprite = SDLx::Sprite->new( image => 'img/tile/tile2.png', # or surface => SDL::Surfac +e x=>int rand(500)-20, y=>400 ); } 1 .. 50; # .... etc ..... for(@tile2){ $_->draw_xy($app,$_->x,$_->y); }

    Perl Monks please guide me.

Yet another spawn question. Portable method?
3 direct replies — Read more / Contribute
by MickeyLane
on Sep 16, 2017 at 09:24

    I know that this question has been asked 500 times over the last dozen or more years and I've read most of the answers. Since I'm writing this, the answers don't do what I need. Or I haven't found the One True Answer.

    Design goal #1: Write a Perl script that runs on any platform that supports Perl without special casing.

    Design goal #2: Use the minimum number of manually added packages as possible.

    The script runs through a list of possible jobs to do. When it (A) finds one, it 'locks' that job and spawns another instance of the script (B) to continue looking for jobs. When A finishes, it unlocks the job and dies. B becomes the only instance running (the new A). Lather, rinse, repeat.

    Question: What is a single platform independent way of spawning another instance of the running script?

    The code below needs to be saved as "spawn.pl"

    #!/usr/bin/perl use warnings; use strict; use Proc::Background; my $arg = shift @ARGV; if (!defined ($arg)) { print ("Usage: \"perl spawn.pl n\" where n is the number of times +to spawn\n"); exit (0); } my $c = $arg + 0; print ("Starting PID $$ as instance $c\n"); if ($c > 0) { $c--; sleep (2); if (1) { # # This only works on Windows (as is well noted) # system (1, "perl spawn.pl $c"); } elsif (0) { # # This does not work on Windows because it doesn't have the fu +ll path # Same on Linux Mint (Ubuntu or Debian) # my $arg1 = "$c"; # my $command = "perl spawn.pl"; my $command = "spawn.pl"; my $proc1 = Proc::Background->new ($command, $arg1); } elsif (0) { # # Does not work on Windows because it waits for completion # Works on Linux Mint # system ("perl spawn.pl $c &"); } else { # # Need something here # } } sleep (3); print ("PID $$ ended\n"); exit (0);
problem with Crypt::PBKDF2
1 direct reply — Read more / Contribute
by jamroll
on Sep 15, 2017 at 22:44
    okay. so i have a script, "create_account.pl" which spits out this error:

    Use of uninitialized value in subroutine entry at /usr/local/share/perl/5.24.1/Crypt/PBKDF2/Hash/HMACSHA1.pm line 19.

    i've done some "debugging" and have found the error happens on this line of "create_account.pl": $account{password} = $pb->generate($account{passwordagain});

    I even tried to change it to:

    my $temp = $pb->generate($account{password}); no dice!

    yet, my "setstats.pl" script doesn't issue the error and the code is pretty much exactly the same stuff:

    my $newdbpw = $pb->generate($newpw);

    so...do i need to post ALL of the code, or is this enough to get us started?

    some system stats? ubuntu 17.04 and perl5.24.1

    Sincerely, Jarett

Swap Ascii chr() for null string
7 direct replies — Read more / Contribute
by PriNet
on Sep 15, 2017 at 16:52
    Simple simple question for someone who's actually done it...
    Why doesn't $String =~ s/chr(12)//g; work?

    Has anyone seen this sliced bread thing? I's better than... sliced... well... never mind...
MySQL DB Connection
4 direct replies — Read more / Contribute
by clm314159
on Sep 15, 2017 at 11:13

    Hi, I'm trying to show someone how to connect to a MySQL DB with Perl. I've done this before but it was about 10 years ago. I know it is a pretty straight forward process except it is full of little details that must all be addressed. So my question is, Does anyone know of a good up to date tutorial for doing this on Windows? The ones I've been finding are either not for MySQL and there is the problem of interpreting the info from one DB to MySQL (currently I'm working from an oracle tutorial trying to install the driver, the oracle driver is clearly labelled as such but I cannot find a MySQL driver that is clearly labelled in the ppm) or the tutorial is 15 years out of date.

    Any info you could point me at would be appreciated,

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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (6)
    As of 2017-09-19 12:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      During the recent solar eclipse, I:









      Results (220 votes). Check out past polls.

      Notices?