Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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
Perl tk module
No replies — Read more | Post response
by Anonymous Monk
on May 27, 2020 at 09:32

    I am trying to use Tk module to create a simple GUI. I would like to get the "Save and exit" button to be located at most bottom position in the GUI. When running my code below, the button is somewhere in the middle of the GUI. I have tried with -side option.

    use Tk; my $mw = MainWindow->new(-title => 'IP User config form'); my $label2 = $mw->Label(-text => 'Part 1: Mandotory fields filling'); $label2->pack(); my $f1 = $mw->Frame(-borderwidth => 2, -relief => 'groove', -width => +30) ->pack(-side => 'top', -fill => 'both', -expand => 1); my $f2 = $mw->Frame(-borderwidth => 2, -relief => 'groove', -width => +30) ->pack(-side => 'top', -fill => 'both', -expand => 1); $f1->Label(-text => 'Config ID')->grid($f1->Entry(-textvariable => \$d +ss_config_id), $f1->Label(-text => 'Milestone ID'), $f1->Entry(-textvariable => \$milestone_id), -sticky => 'w', -padx => +2, -pady => 5); $f1->Label(-text => 'IPX_FQN')->grid($f1->Entry(-textvariable => \$ipx +_fqn), $f1->Label(-text => 'IPX NEWLINE'), $f1->Entry(-textvariable => \$ipx_new_line), -sticky => 'w', -padx => 2, -pady => 5); $f1->Label(-text => 'IPX consumer groups')->grid($f1->Entry(-textvaria +ble => \$ipx_consumer_grp), $f1->Label(-text => 'IPP Tag'), $f1->Entry(-textvariable => \$ipp_tag), -sticky => 'w', -padx => 2, -pady => 5); $f1->Label(-text => 'Process')->grid($f1->Entry(-textvariable => \$pro +cess), $f1->Label(-text => 'Runset version'), $f1->Entry(-textvariable => \$runset_ver), -sticky => 'w', -padx => 2, -pady => 5); $f1->Label(-text => 'UPF version')->grid($f1->Entry(-textvariable => \ +$upf_ver), $f1->Label(-text => 'Contact (username:contact_type)'), $f1->Entry(-textvariable => \$contact), -sticky => 'w', -padx => 2, -pady => 5); #my $label3 = $mw->Label(-text => 'Release Notes Enabling', -relief=>' +groove')->pack(-fill => 'x', -side => 'bottom'); my $label3 = $mw->Label(-text => 'Release notes'); $label3->pack(); my $values2; my @chk_boxes2 = ( [\$values2->{notes},'Notes'], [\$values2->{issues},'Issues'], [\$values2->{comments},'Comments'], [\$values2->{changes},'Changes'], ); check_box2(\@chk_boxes2); $f2->pack(); my $button = $mw->Button(-text => "Save and exit", -command => \&reFor +m)->grid('-', '-', '-', -pady => 10)->pack(-side=>'bottom'); $f2->pack(); MainLoop; sub check_box2 { my $data = shift; my $index = 0; for my $chk_box ( @{$data} ) { my $column = $index % 2; my $row = int($index/2); my $chk_x = $f2->Checkbutton( -text => $chk_box->[1], -variable => $chk_box->[0] )->grid( -column => $column, -row => $row, -sticky + => 'w'); #$chk_x->select if $index == 0; $index++; } my $chk_x=$f2->pack(-side=>'bottom'); }
one liner error
2 direct replies — Read more / Contribute
by toohoo
on May 27, 2020 at 01:57

    Hello everybody

    I just tried to test an one liner.

    perl -e use Cwd; print getcwd();

    In this I get an error
    If I put this in a perl script file and run then all is fine.
    What I'm doing wrong?

    I'm under Windows 10 perl 5, version 26, subversion 2 (v5.26.2) built for x86_64-msys-thread-multi

    Thanks in advance, best regards

perl compile time options
1 direct reply — Read more / Contribute
by dheffx
on May 26, 2020 at 14:12
    Hi,

    We currently use 5.18.4 in production but as we move from Centos 6 -> Amazon Linux 2 there is a desire to bring our version of Perl up to date along the way. When I am building 5.30.2, I notice the compile time options by default are different than the ones used for the 5.18.4 package. I could not find any useful documentation on the Perl compile time operators. Am I just missing some documentation on these? If so a pointer in the right direction would be appreciated. If not, there are two in particular that were used for 5.18.4 but not 5.30.2 that I am having trouble digging up what they actually do: PERL_HASH_FUNC_ONE_AT_A_TIME_HARD and PERL_SAWAMPERSAND. Would appreciate some help understanding the impact of these two flags.

    Thanks!
cpnam GD error
4 direct replies — Read more / Contribute
by Jerry_J
on May 26, 2020 at 11:12

    I just received the Martien Verbruggen bood "Graphics Programming with Perl". After reading the first 20 pages, I liked the book and decided to install the GD module. I am running Windows 10 with Active Perl: "perl 5, version 20, subversion 2 (v5.20.2) built for MSWin32-x64-multi-thread" When I try to install GD via cpanm I receive the following:

    C:>cpanm GD --> Working on GD Fetching http://www.cpan.org/authors/id/R/RU/RURBAN/GD-2.71.tar.gz ... + OK Configuring GD-2.71 ... N/A ! Configure failed for GD-2.71. See C:\Users\Jerry\.cpanm\work\1590342 +755.3924\build.log for details.

    The build log has the following error:

    cpanm (App::cpanminus) 1.7044 on perl 5.020002 built for MSWin32-x64-m +ulti-thread Work directory is C:\Users\Jerry/.cpanm/work/1590342755.3924 You have make C:\Perl64\site\bin\dmake.exe You have LWP 6.44 Falling back to Archive::Tar 2.04 Searching GD () on cpanmetadb ... --> Working on GD Fetching http://www.cpan.org/authors/id/R/RU/RURBAN/GD-2.71.tar.gz -> OK Unpacking GD-2.71.tar.gz Entering GD-2.71 Checking configure dependencies from META.json Checking if you have ExtUtils::PkgConfig 0 ... Yes (1.16) Checking if you have ExtUtils::Constant 0.22 ... Yes (0.23) Configuring GD-2.71 Running Makefile.PL Notice: Type perl Makefile.PL -h for command-line option summary. 'gdlib-config' is not recognized as an internal or external command, operable program or batch file. Package gdlib was not found in the pkg-config search path. Perhaps you should add the directory containing `gdlib.pc' to the PKG_CONFIG_PATH environment variable No package 'gdlib' found at Makefile.PL line 449. *** can not find package gdlib *** check that it is properly installed and available in PKG_CONFIG_PA +TH at Makefile.PL line 449. -> N/A -> FAIL Configure failed for GD-2.71. See C:\Users\Jerry\.cpanm\work\1 +590342755.3924\build.log for details.

    I searched my computer and the gdlib.pc file is not on my machine. Being very much a novice on debugging these types of errors, I am hoping other can help me with getting this GD module installed. Any help you can provide is appreciated.

Appending /*.* to default Perl variable $_
2 direct replies — Read more / Contribute
by geertvc
on May 26, 2020 at 03:35
    First time ever post here...

    I have an array with directory names:
    my @codeOutputDirs = ( "output/$harvester$flavour/layout", "output/$harvester$flavour/tabview", "output/$harvester$flavour/udw", "output/$harvester$flavour/values", "output/$harvester$flavour/udw/service", "output/$harvester$flavour/udw/cfg" );
    The variables $harvester and $flavour are passed as parameters on the command line when calling the Perl script.

    I want to use a for loop to go through the array and do some stuff like so:
    make_path "output/$harvester$flavour/layout"; unlink glob "output/$harvester$flavour/layout/*.*";
    And this, for each and every element in the array.

    For this, I'm using the following Perl-ish (I guess?) way of traversing through each and every element of the array:
    for (@codeOutputDirs) { make_path $_; unlink glob $_/*.*; }
    The first command, make_path $_; is fine.
    However, the second command has issues when I append /*.* to the default variable $_

    Can someone tell me how to accomplish this using the correct syntax? Putting $_ between {} doesn't seem to be the solution.

    Best,
    --Geert
Drawing A Dichotomous Key
3 direct replies — Read more / Contribute
by varanasi
on May 25, 2020 at 15:52

    I would like to draw, and ultimately print, a dichotomous key. A dichotomous key works rather like a flowchart or decision tree with a yes/no choice at each node. There's an explanation with some nice examples of possible pictures here: https://creately.com/blog/diagrams/what-is-a-dichotomous-key/

    I suspect that what I need is in cpan, but I've searched cpan without success.

How to substitute all tabs only in a specific field
6 direct replies — Read more / Contribute
by xuo
on May 25, 2020 at 09:33
    Hi,

    I'm asking again for your help.
    I know the title seems quite obvious but it is something I was not able to do.
    Here is my input file :
    a b x1 x2
    c d x2
    e f x3 x4 x5

    And I want it to become :
    a b x1,x2
    c d x2
    e f x3,x4,x5

    In other words, I want to substitute all <tabs/space> in the field that starts and ends with <double quotes> by <commas>.
    The number of fields between quotes can be of any value (practically it will never be greater than 6 or 7 but I'd like something generic).
    And I want to do this (if possible) on a unix command line ie :
    perl -pe 's/.../g' < input_file > output_file.

    Do you know how to achieve this ?

    Regards.

    Xuo.
sendmail working for me but not another
3 direct replies — Read more / Contribute
by kickingchicken
on May 25, 2020 at 08:12

    Hello, I am using sendmail to send form data to 3 emails. Then the user is sent to a confirmation page. It works for me, and others as I am receiving emails, but for a few others it does not. They are being sent to the confirmation page but no emails are ever sent out. Am I doing something wrong, or is this server related?

    #!/usr/bin/perl use CGI qw/:standard/; $CGI::POST_MAX=1024 * 1; #$CGI::Validate::IgnoreNonMatchingFields = 1; $fstname = substr param ('first'), 0, 40; $lstname = substr param ('last'), 0, 40; $adda = substr param ('1ad1a'), 0, 60; $addb = substr param ('1ad1b'), 0, 60; $city = substr param ('1ad2'), 0, 60; $state = substr param ('1ad3'), 0, 20; $zip = substr param ('1ad4'), 0, 5; $email = substr param ('eadd'), 0, 70; $phone = substr param ('pnum'), 0, 16; $residence = substr param ('residence'), 0, 9; $yardtype = substr param ('yardtype'), 0, 16; $yardtypeother = substr param ('yardtypeother'), 0, 40; $landlord = substr param ('landlord'), 0, 40; $preadda = substr param ('2ad1'), 0, 60; $precity = substr param ('2ad2'), 0, 60; $prestate = substr param ('2ad3'), 0, 20; $prezip = substr param ('2ad4'), 0, 5; $alone = substr param ('alone'), 0, 14; $household = substr param ('household'), 0, 100; $vet = substr param ('vet'), 0, 45; $pet = substr param ('pet'), 0, 3; $petname = substr param ('petnme'), 0, 30; $currentpets = substr param ('currentpets'), 0, 60; $previouspets = substr param ('previouspets'), 0, 60; $references = substr param ('references'), 0, 140; $ok = substr param ('ok'), 0, 7; ## Clear out unwanted characters $fstname =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $lstname =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $adda =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $addb =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $city =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $state =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $zip =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $email =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $phone =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $residence =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $yardtype =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $landlord =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $preadda =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $precity =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $prestate =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $prezip =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $alone =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $household =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $vet =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $pet =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $petname =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $currentpets =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $previouspets =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $references =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $ok =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $email =~ tr/[A-Z]/[a-z]/; ## Check email address if (($email ne "") && ($email !~ m/[\w]+@[\w]+\.[\w]+/)) { print "Content-type: text/html\n\n"; print "error (Your email is invalid, please check and resubmit you +r application)</ br></ br>"; exit; } ## Check data $total_form = "$fstname$lstname$email"; if (length($total_form) < 25) { print "Content-type: text/html\n\n"; print "error (The form was incomplete, please check that you fill +ed in your full first and last name, and email address, then resubmit + your application.)</ br></ br>"; exit; } # residence replace with response ##if ($residence eq "1") ## { ## $residence = "House" ## } ##if ($residence eq "2") ## { ## $residence = "Apartment" ## } $recipient = "email1\@emailsrv1, email2\@emailsrv2, email3\@emailsrv3" +; ## Create the email message body $email_message = qq{To: $recipient Subject: Adoption Application From: $fstname $lstname<$email> First name: $fstname Last name: $lstname Current address: $adda $addb $city $state $zip _________________________________________________ Email address: $email Phone number: $phone Type of residence: $residence Yard: $yardtype Landlord contact info: $landlord Previous address: $preadda $precity $prestate $prezip How many hours will pet be alone: $alone Name and age of people in household: $household Veterinarian: $vet Dog or Cat: $pet Name of pet requested: $petname Current pets: $currentpets Previous pets: $previouspets References: $references Aggree to consent form: $ok }; ## Send email $mailprog = '/usr/sbin/sendmail'; open (MAIL, "|$mailprog -t"); print MAIL $email_message; close (MAIL); print "Location: application-submitted \n\n"; exit; __END__
ExtUtils::MakeMaker - VERBINST unknown
1 direct reply — Read more / Contribute
by kcott
on May 25, 2020 at 02:54

    I haven't used the VERBINST previously but tried it today:

    WriteMakefile( ..., VERBINST => 1, ... );

    I got messages saying this parameter was unknown:

    $ perl Makefile.PL WARNING: VERBINST is not a known parameter. Checking if your kit is complete... Looks good 'VERBINST' is not a known MakeMaker parameter name. Generating a Unix-style Makefile ...

    I did a Super Search for VERBINST. There were only four results; three showed the generated Makefile which, in each case, had:

    # --- MakeMaker tools_other section: ... VERBINST = 0 ...

    Curiously, my generated Makefile had:

    # --- MakeMaker tools_other section: ... VERBINST = 1 ...

    I continued on with make, make test and make install. The last of those was supposed to be verbose but I only got the normal output:

    $ make install Manifying 1 pod document Installing /.../lib/site_perl/...pm Installing /.../man/man3/...3pm Writing /...packlist Appending installation info to /.../perllocal.pod

    I'm using Perl v5.30.0 (built for cygwin-thread-multi) and ExtUtils::MakeMaker v7.34.

    I've checked the documention, "ExtUtils::MakeMaker (for Perl v5.30.0)", and I'm reasonably certain that I'm using VERBINST correctly.

    Any ideas on whether I've done something wrong or if there's a bug, would be appreciated.

    — Ken

cpanm mysql fails with errors
4 direct replies — Read more / Contribute
by vskatusa
on May 24, 2020 at 16:44
    Hi, I have the following configuration:
    • ubuntu 16.04.6 LTS
    • perl 5, version 22
    • mysql Ver 14.14 Distrib 5.7.30
    I tried to install mysql with the following command
    cpanm DBD::mysql

    And get FAIL Configure failed for DBD-mysql-4.050. See /root/.cpanm/work/1590352522.4014/build.log for details Here is the build.log

    From the log it appears that it is not able to access mysql_config but I am not sure how to resolve this?

    cpanm (App::cpanminus) 1.7044 on perl 5.022001 built for i686-linux-gn +u-thread-multi-64int Work directory is /root/.cpanm/work/1590352522.4014 You have make /usr/bin/make You have LWP 6.44 You have /bin/tar: tar (GNU tar) 1.28 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gp +l.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason. Searching DBD::mysql () on cpanmetadb ... --> Working on DBD::mysql Fetching http://www.cpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.t +ar.gz -> OK Unpacking DBD-mysql-4.050.tar.gz Entering DBD-mysql-4.050 Checking configure dependencies from META.json Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.04_01) Checking if you have Data::Dumper 0 ... Yes (2.173) Checking if you have Devel::CheckLib 1.09 ... Yes (1.14) Checking if you have DBI 1.609 ... Yes (1.643) Configuring DBD-mysql-4.050 Running Makefile.PL Can't exec "mysql_config": No such file or directory at Makefile.PL li +ne 89. Cannot find the file 'mysql_config'! Your execution PATH doesn't seem not contain the path to mysql_config. Resorting to guessed values! PLEASE NOTE: For 'make test' to run properly, you must ensure that the database user 'root' can connect to your MySQL server and has the proper privileges that these tests require such as 'drop table', 'create table', 'drop procedure', 'create procedure' as well as others. mysql> grant all privileges on test.* to 'root'@'localhost' identified + by 's3kr1t'; You can also optionally set the user to run 'make test' with: perl Makefile.PL --testuser=username Can't exec "mysql_config": No such file or directory at Makefile.PL li +ne 603. Failed to determine directory of mysql.h. Use perl Makefile.PL --cflags=-I<dir> to set this directory. For details see DBD::mysql::INSTALL, section "C Compiler flags" or type perl Makefile.PL --help Can't find mysql_config. Use --mysql_config option to specify where my +sql_config is located -> N/A -> FAIL Configure failed for DBD-mysql-4.050. See /root/.cpanm/work/15 +90352522.4014/build.log for details.

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 lurking in the Monastery: (7)
    As of 2020-05-27 13:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      If programming languages were movie genres, Perl would be:















      Results (155 votes). Check out past polls.

      Notices?