Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

If you're new here please read PerlMonks FAQ
and Create a new user.

poll ideas quest 2021
Starts at: Jan 01, 2021 at 00:00
Ends at: Dec 31, 2021 at 23:59
Current Status: Active
11 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
CPAN clients exposed to sig-related vulnerabilities
on Nov 23, 2021 at 18:06
1 reply by hippo

    TL;DR - your CPAN client may be vulnerable to modified tarballs from untrusted mirrors (and will have been that way forever). Upgrade, force https, force signature verification and ensure it uses a trusted mirror by default.

    See the post listing the vulnerabilities and this in-depth explanation of what is vulnerable and what to do about it.


Sad News: David H Adler (DHA) has passed away
on Nov 22, 2021 at 18:07
1 reply by eyepopslikeamosquito

    Very sad to learn today of the recent passing of the lovely David H Adler Esq.

    Though I never met dha in person, I remember his delightful sense of humour from the mailing list years ago. I thought it strange that DHA was in New York, while I was in Sydney, yet we both relished the quirky sense of humour of the super-active mailing list back then.

    DHA's love of the fun side of Perl culture is also revealed in his only CPAN module: Semi::Semicolons

Import Constants From File to Templates?
4 direct replies — Read more / Contribute
by varanasi
on Dec 04, 2021 at 08:14

    Everlastingly Helpful Monks:

    I have a module that contains a lot of constants for a web application. I also have many template toolkit templates that use varying sets of those constants. I'd like to include those constants in all my templates directly from my constants module rather than importing them to my script and then remembering to set the ones I need each time I process a template.

    Here's an example of my constants module:

    package Sam::Constants; use strict; use warnings; use base 'Exporter'; use constant PRE => 1; use constant REGULAR => 2; use constant POST => 3; our @EXPORT_OK = qw( PRE REGULAR POST ); 1;

    I've fiddled with toolkit's PREPROCESS and STASH directives but got nowhere.

    Thank you.

    EDIT - here's an example of how I use the constants . . . .

    ---- list_txt.tt2 Here's a list for [% date %]: [% IF type == PRE %] PRE LIST [% list %] [% ELSIF type == REG %] REG LIST [% list_alt %] [% END %] [% INCLUDE email_footer_txt.tt2 %]

    Here's roughly how the script currently uses the template . . .

    use Sam::Constants qw(REG PRE POST); ... $content_ref->{PRE} = PRE; $content_ref->{REG} = REG; $content_ref->{list} = $list; $content_ref->{list_alt} = $list_alt; # for mailer and pass content variable to template my %email_args = ( from => $pool_ref->email, bcc => $pool_ref->admin->email1, text_template => 'list_txt.tt2', content_ref => $content_ref, ); require Template; my $tt = Template->new( { INCLUDE_PATH => $BASE_DIR . '/root/src/', INTERPOLATE => 1, } ) || die "$Template::ERROR\n"; $tt->process( $email_args{text_template}, $email_args{content_ref} ) || die $tt->error(), "\n";
    I'd like to avoid having to put lines like these in my scripts:
    $content_ref->{PRE} = PRE; $content_ref->{REG} = REG;
TK Placing Widgets in a Scrolling Pane
4 direct replies — Read more / Contribute
by saiftynet
on Dec 02, 2021 at 17:28
    Dear Monks,

    I am learning Perl and GUI development, and working currently on code that will work on multiple toolkits (Tk, Wx, Gtk etc). I need help with Tk. For my purposes I have to place all my widgets (rather than pack->() them). I wish to create a fixed sized, fixed position scrolling Listbox, to be later populated by other items. This works perfectly well if I insert strings, I appear not to be able to insert other widgets (e.g Checkbuttons).

    #!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; $mw->geometry('400x250'); my $canvas = $mw->Canvas( -bg => 'lavender', -relief => 'sunken', -width => 400, -height => 250)->pack(-expand => 1, -fill => 'both'); my $size=[200,200]; # size of the widget my $location=[50,12]; # position of widget my @strings2 = qw/apples bananas pears grapes/ x 5; $canvas->{"listbox"}=$mw->Scrolled("Listbox", -bg => 'white', -scrollbars => "e", -selectmode => 'extended', -width => (${$size}[0])/7, # some scaling -height => (${$size}[1]+12)/15); # scaling $canvas->{"listbox"}->insert('end',@strings2); # This works $canvas->createWindow(${$location}[0] ,${$location}[1], -anchor => "nw", -window => $canvas->{"listbox"}); MainLoop();
    Have searched many places, and most suggest I should use pack->(), but I guess mixing pack and place does not work, and I am committed to use pack for my use-case. Your guidance will be gratefully received,


require and use strict vars
4 direct replies — Read more / Contribute
by karlberry
on Dec 02, 2021 at 12:58
    Occasionally I want to "require" a module, rather than "use" it (to avoid loading it at compile-time) and still "use strict". What is the best way to handle variable references into the module? My example:
    use strict; use warnings; require Data::Dumper; local $Data::Dumper::Indent = 0;
    yields Name "Data::Dumper::Indent" used only once: possible typo. I am not surprised by the warning, require happening at runtime and all; the question is how to get rid of it.

    Clearly "use vars" and "our" do not help, since they don't take variable names in another module. Specifying "no warnings 'once'" works, but I don't want to turn off these warnings in general, just because I want to set a module's configuration variable.

    The only way I have found to avoid the warning is to add some additional null usage, as in:

    $Data::Dumper::Indent = $Data::Dumper::Indent;
    This does not seem like it should be necessary. I feel like I'm missing something obvious, but I'm failing to discern the answer. Documentation reading and web searches have not been successful. Thanks for any info ...
Verify Town Name
4 direct replies — Read more / Contribute
by PilotinControl
on Nov 29, 2021 at 19:34

    Hello Fellow Monks!
    I have a perplexing issue with my code below. I am trying to verify a town name located in a file using it as a check and balance before moving on to the next user input. However no matter what is inputted it moves on with out giving notice stating the town name has not been found. Thanks in advance!

    sub addind { open(MYINPUTFILE, "townsdata.txt"); # OPEN FOR INPUT $| = 1; my @lines = <MYINPUTFILE>; # READ FILE INTO LIST print "INDUSTRY TOWN\n"; my $indtwn = <STDIN>; $indtwn = <STDIN> until defined $indtwn; chomp $indtwn; cls(); my $found = 0; foreach my $townverify (@lines) { my @field = split(':',$townverify); if ($field[0] =~ m/^#/) { next; } if ($field[1] =~ /(?<![\w-])$indtwn(?![\w-])/i) { cls(); $found = 1; } else { cls(); print "TOWN RECORD NOT FOUND\n"; sleep 3; cls(); addind(); } # END FOREACH FILE LOOP my $output="inddata.txt"; open(DAT,"+<$output") || die("Cannot Open File"); my $indline; $indline = <DAT> until eof DAT; my ($indid) = $indline =~ m/\A(\d+):/; print DAT (++$indid); print DAT (":"); print DAT ($indtwn); print DAT ("\n"); close (DAT); print "INDUSTRY SUCCESSFULLY ADDED!!\n"; sleep 3; cls(); industry(); }
    2:PGHW:Pittsburgh West End

To not capture recursive group while collecting certain matches
4 direct replies — Read more / Contribute
by Anonymous Monk
on Nov 29, 2021 at 04:55
    How regex match must not capture recursive group used and required inside when collecting all the matched captured groups?
    just illustration
    How to manage m contains all matched kv correctly clean from matched recursive ?
Recalling a function iteratively
3 direct replies — Read more / Contribute
by dnamonk
on Nov 28, 2021 at 21:18
    Dear Monks, I have a general logic question. I need help in logic and not code. I have a question about recalling my function within a loop. Below is my code:
    List_new = myfunction() for items in List_new: if(my condition is TRUE): Execute some commands if(my condition is FALSE): recall myfunction()
    My problem is that I am loading "List_new" using myfunction(). How can I change "List_new" iteratively when my condition is False. I want to reload the function especially when the condition is FALSE. This means I keep calling the function until it is false and then execute the final output from myfunction(). Thank you in advance for your help.
PerlMonks Discussions
Zombified user account on Selected Best Nodes
4 direct replies — Read more / Contribute
by Athanasius
on Dec 01, 2021 at 02:12

    Just noticed, Selected Best Nodes currently has dem bones in 12th place with a Rep of 137. This caught my eye because zombified accounts are supposed to have no write-ups. And no, this one doesn’t have any write-ups — the high-ranking node is the user page itself! I’m thinking something may be amiss here... ??

    Thanks for looking,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?

What's my password?
Create A New User
Domain Nodelet?
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: (2)
As of 2021-12-05 11:03 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (31 votes). Check out past polls.