Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

The Monastery Gates

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

Donations gladly accepted

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

New Questions
Jenkins and Perl
2 direct replies — Read more / Contribute
by blue_cowdawg
on Aug 03, 2015 at 15:14

    I just discovered Jenkins and I'm having a blast with it having discovered all sorts of things I can do with it.

    Looking at the plethora of plugins available I discovered a couple of plugins having to do with Perl that don't seem to be documented. These are:

    • Perl Plugin
    • Perl Smoke Test Plugin
    Sadly there doesn't seem to be any documentation for them. Is there and I'm just not finding it?


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; Blog: http://blog.berghold.net Warning: No political correctness allowed.
Tie::File, is unite file handle must?
1 direct reply — Read more / Contribute
by stm
on Aug 03, 2015 at 08:59

    Hello,

    This question is related to Tie::File module. Have opened a file and processing array functions. Then processing do while loop, here the script has to exit if conditions are met.

    Is it OK to use exit to exit the script without untie the file handle ? or any better solution available? last statement is not working here. It says an error "Can't "last" outside a loop block at". Copied few lines of my code to keep simple.

    tie my @in_array, 'Tie::File', $fileA, mode => O_RDWR or die $!; my $f_cnt = scalar(@in_array); my $retries; do { ##have removed lines for simplicity ## $retries++; if ($retries > 3) { print "3 attempts are failed.\n"; exit(); } } while ($f_cnt > 1 ); untie @in_array;
Forcing DBIx::Class::AuditLog to install to the System perl's path
3 direct replies — Read more / Contribute
by davis
on Aug 03, 2015 at 05:10

    Been a while...

    I'm trying to install DBIx::Class::AuditLog. I want it to be available system-wide, so I'm using CPAN or cpanm as root on my CentOS 7 box to install it. Other modules installed system-wide, as expected, but D:C:AL (and it alone) seems to go to root's home directory, and I'm not sure why: Here's what I tried:

    cpan[7]> install DBIx::Class::AuditLog Running install for module 'DBIx::Class::AuditLog' Running make for I/IO/IONCACHE/DBIx-Class-AuditLog-0.6.2.tar.gz Fetching with LWP: http://cpan.ulak.net.tr/authors/id/I/IO/IONCACHE/DBIx-Class-AuditLog-0 +.6.2.tar.gz Fetching with LWP: http://cpan.ulak.net.tr/authors/id/I/IO/IONCACHE/CHECKSUMS Checksum for /root/.cpan/sources/authors/id/I/IO/IONCACHE/DBIx-Class-A +uditLog-0.6.2.tar.gz ok Scanning cache /root/.cpan/build for sizes DONE CPAN.pm: Building I/IO/IONCACHE/DBIx-Class-AuditLog-0.6.2.tar.gz Created MYMETA.yml and MYMETA.json Creating new 'Build' script for 'DBIx-Class-AuditLog' version '0.6.2' Building DBIx-Class-AuditLog IONCACHE/DBIx-Class-AuditLog-0.6.2.tar.gz ./Build -- OK Running Build test t/001_deploy.t ....................... ok t/002_cud.t .......................... ok t/003_get_changes.t .................. ok t/004_force_auditlog.t ............... ok t/005_modify_audit_value.t ........... ok t/006_resultsets-default_rs_class.t .. ok t/007_resultset-loadcomponent.t ...... ok t/008_relationships.t ................ ok t/009_recursive-update.t ............. ok t/010_bug_undef_columns_logged.t ..... ok t/011_update_on_deleted_row.t ........ ok t/012_cud_view.t ..................... ok t/release-pod-syntax.t ............... skipped: these tests are for re +lease candidate testing All tests successful. Files=13, Tests=76, 12 wallclock secs ( 0.09 usr 0.02 sys + 9.94 cus +r 0.73 csys = 10.78 CPU) Result: PASS IONCACHE/DBIx-Class-AuditLog-0.6.2.tar.gz ./Build test -- OK Running Build install Building DBIx-Class-AuditLog Installing /root/perl5/lib/perl5/DBIx/Class/AuditLog.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure. +pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +AuditedTable.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +Field.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +Base.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +Action.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +Change.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +Changeset.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +User.pm Installing /root/perl5/lib/perl5/DBIx/Class/Schema/AuditLog/Structure/ +View.pm Installing /root/perl5/lib/perl5/DBIx/Class/ResultSet/AuditLog.pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::View.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::User.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::Action.3pm Installing /root/perl5/man/man3/DBIx::Class::ResultSet::AuditLog.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::Change.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::Base.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::AuditedTable.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::Field.3pm Installing /root/perl5/man/man3/DBIx::Class::Schema::AuditLog::Structu +re::Changeset.3pm Installing /root/perl5/man/man3/DBIx::Class::AuditLog.3pm IONCACHE/DBIx-Class-AuditLog-0.6.2.tar.gz ./Build install -- OK

    Can I simply move the files out of ~/perl5 into /usr/local/share/perl5/ (where other modules have happily installed)? I've completely blown away .cpan and tried again, and tried cpanm, so this problem seems specific to the module. Any ideas?


    davis

Win32::GUI won't display an NI menu properly
3 direct replies — Read more / Contribute
by wardmw
on Aug 03, 2015 at 04:59
    Greetings honoured friars,

    I have a program that creates an icon in the system tray of Windows 7 and displays a tool-top when the mouse is hovered over it.

    The issue comes when the user right-clicks the icon, it should display a menu but instead I get a thin sliver of a window, like a menu but with no text (the word "File" in this case). Something is there as if I click where "File" should be I get a sub-menu, no problem, I just cannot see the word "File".

    I have worked through the articles elsewhere on Perlmonks but to no avail, even the "traymon.pl" code has this same problem, at least on my machine anyway.

    The following code shows this exact problem, feel free to change the icon path to any .ICO file you have spare, or leave it blank and right-click in the blank space that will appear in your system tray.

    # A simple Perl program to show the fly-out menu problem. # Uses and requires use strict; use Win32::GUI(); my $win_main; # Pointer to the main window. my $menu_popup; # Pointer to the menu that should appear. my $icn; # Ptr to an icon. my $debug = 1; # Debug flag # Windows event handlers go here. sub Main_Terminate { $win_main->NI->Remove(); -1; } sub NI_RightClick() { print "NI_RightClick event called.\n" if ($debug); $win_main->TrackPopupMenu($menu_popup, Win32::GUI::GetCursorPo +s()); } # Main program start # First, build everything # Create the context menu to be displayed when the icon is right-click +ed # Translate the menu $menu_popup = Win32::GUI::Menu->new( "&File" => "File", ">E&xit" => { -name => "File_Exit", -onClick => sub{-1} + }, ); # Create the main window - this will not be displayed. $win_main = Win32::GUI::Window->new( -name => 'Main', -menu => $menu_popup, -width => 1, -height => 1, -text => '', ); # Create an icon that will appear in the system tray. Pick any icon yo +u want. $icn = new Win32::GUI::Icon("c:/Windows/System32/PerfCenterCpl.ico"); # Add the icon to the window. $win_main->AddNotifyIcon( -name => 'NI', -icon => $icn, -tip => 'Thi is a notify fly-out/tool-tip thing.', -balloon => 0, ); # Enter the Windows message loop Win32::GUI::Dialog();
    I would appreciate your thoughts on this, or even a simple test to see if this code works on your system (in which case it is environmental, but I still have no clue as to what it might be!)

    |\/|artin

Difference between leftward and rightward list operators
3 direct replies — Read more / Contribute
by Firsov
on Aug 01, 2015 at 02:25

    Greetings!

    I was reading perlop manual. And i don't understand one thing: What difference between rightward and leftward list operators?

    I guess that leftward list operator this is function that accept LIST (has higher precedence that comma operator). But what is a right ward list operator and why it has low precedence?

Perl Debugger rcfile on Windows
1 direct reply — Read more / Contribute
by VinsWorldcom
on Jul 31, 2015 at 15:14

    Windows Monks - has anyone gotten the Perl Debugger rcfile (.perldb / perldb.ini) to work on Windows? I can use the Perl debugger fine with 'perl -d <progfile> [args]', but if I have a .perldb (perldb.ini) file defined, I get mixed, unsatisfying results.

    I'm on Windows 7 x64 with Strawberry 5.18.1.

    Essentially I've tried .perldb and perldb.ini in both the current directory and my home directory. It seems only perldb.ini is recognized and when it finds it, regardless of location, I get the error:

    perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner.

    So I've tried to modify permissions of the perldb.ini file on Windows by breaking the parent inheritance on that file and making sure I'm the owner and the only one with "Full Permissions" - which still doesn't fix the problem.

    Anyone get this working successfully?

    UPDATE: I've narrowed it down in perl5db.pl.

    'use vars qw($rcfile);' does a check which for Windows will return 'perldb.ini' regardless explaining why '.perldb' has no effect, despite POD about running interactive vs non- mode.

    Then, that 'perldb.ini' file is (eventually) run through "sub is_safe_file" which does a 'stat()' and on Windows, is obviously not returning the proper value to create a false when bit-masked with 022. See the function in perl5db.pl for more details as well as POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux, which has the mode value I'm getting "33206" on Windows.

    That being said, I could do all sorts of things to fix this by editing perl5db.pl, but is there a way / argument /something to get this to work without me monkeying with a module's code?

Perl system command memory usage in threads
4 direct replies — Read more / Contribute
by rmahin
on Jul 31, 2015 at 14:24

    SOLVED Updated to perl 5.20.2 and all problems vanished.

    Hello! Been noticing some strange memory issues with a script I'm working on, and have come up with this to highlight the issues

    use strict; use warnings; use threads; use threads::shared; $|++; my $DONE :shared = 0; my $lock :shared; my $execMethod = $ARGV[0] || 0; if($execMethod !~ /[12345]/){ print "Must pass an exec method:\n"; print "1 = backticks\n"; print "2 = backticks synchronized\n"; print "3 = open\n"; print "4 = open synchronized\n"; print "5 = system\n"; exit 1; } sub execute{ my $cmd = shift; if($execMethod == 1){ `$cmd` }elsif($execMethod == 2){ lock $lock; `$cmd` }elsif($execMethod == 3){ open(my $fs, "-|", $cmd); foreach(<$fs>){}; close $fs; }elsif($execMethod == 4){ lock $lock; open(my $fs, "-|", $cmd); foreach(<$fs>){}; close $fs; }elsif($execMethod == 5){ system($cmd . ">nul"); } } sub worker{ while(!$DONE){ execute('echo hello world'); } } my @workers = map threads->create( \&worker), (1..30); print "Press <enter> to terminate\n"; <STDIN>; $DONE = 1; $_->join() for @workers;

    Script is invoked with <script>.pl executionMethod

    Question 1 relates to memory usage. Methods 2, 4, and 5 all exhibit a permanent memory creep. Is there a way to fix this and let this script run forever? If the solution is periodically join threads, this is not feasible. I have tried this a couple years ago and came across some bug but outlined in this node and changing to an approach like this would require far too much testing to ensure no other bugs occur. If there really is no solution, would be good to know :)

    Question 2: For methods 1 and 3, why do i need to synchronize them? If I do not, the script just hangs up usually after only a few seconds. Synchronizing this access kind of seems to defeat the purpose of running system commands in threads, is there something I can do differently?

    *I have been running this on Windows 2008 R2, using perl 5.18.2

    Thanks in advance for all your help

    UPDATE 1: Here is the log file from perfmon running test 5 for a little over a minute and eating roughly 150MB.

    UPDATE 2:

    perl -v output

    This is perl 5, version 18, subversion 1 (v5.18.1) built for MSWin32-x +64-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2013, Larry Wall Binary build 1800 [297570] provided by ActiveState http://www.ActiveSt +ate.com Built Sep 20 2013 15:07:17 Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge.

    systeminfo

    Host Name: VCLOUD291 OS Name: Microsoft Windows Server 2008 R2 Enterprise OS Version: 6.1.7601 Service Pack 1 Build 7601 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Server OS Build Type: Multiprocessor Free Registered Owner: Windows User Registered Organization: Product ID: 55041-507-5915375-84291 Original Install Date: 4/23/2014, 12:10:03 PM System Boot Time: 7/31/2015, 1:49:06 PM System Manufacturer: Microsoft Corporation System Model: Virtual Machine System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 46 Stepping 6 +GenuineIntel ~1862 M hz BIOS Version: American Megatrends Inc. 090004 , 3/19/2009 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume1 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC-07:00) Arizona Total Physical Memory: 4,096 MB Available Physical Memory: 1,635 MB Virtual Memory: Max Size: 6,143 MB Virtual Memory: Available: 3,364 MB Virtual Memory: In Use: 2,779 MB Page File Location(s): C:\pagefile.sys Domain: WORKGROUP Logon Server: \\VCLOUD291 Hotfix(s): 46 Hotfix(s) Installed.
How to capture compile errors from child program?
4 direct replies — Read more / Contribute
by bulrush
on Jul 31, 2015 at 06:03
    I have a parent program, parent.pl that calls a child program, child.pl, like this:
    @z=`perl child.pl -option1 -option2`
    
    The whole command line for child.pl is in a scalar variable but that shouldn't matter. So I noticed that @z in parent.pl would return completely blank after I made some changes to child.pl. Lo and behold I had compile or syntax errors in child.pl, so none of my other error messages (written to STDOUT with "print") would be written from child.pl.

    So when I'm running parent.pl, how do I capture compile errors when calling child.pl? Do I have to do something like

    @z=`perl -c child.pl`;
    
    before I do anything else? Will @z return STDERR messages or just STDOUT? If I did
    @z=`perl child.pl -option1 -option2` or die "Possible compile errors in child.pl";
    
    Would that do what I want?

    Thank you. Looking for some input so I can learn more about this.

Replacement for the "unsupported" Graph module?
1 direct reply — Read more / Contribute
by pokki
on Jul 31, 2015 at 05:54

    Hello Monks,

    I've used the Graph module for lots of graph-related tasks and I've always been happy with it. I don't need a superfast module, or one that consumes very little memory, since I don't have many graphs and they aren't very big. I don't need complex operations either; neighbor/descendant/ancestor list, maybe some shortest paths.

    Is there an heir to Graph, now that its author has stopped maintaining it? Or should I just keep using it and hope it doesn't break in the future? What do you guys use, or do you just write your own adjacency maps?

Email Module
4 direct replies — Read more / Contribute
by caseycole589
on Jul 31, 2015 at 03:16

    I'm trying to convince my work to use Perl for our email in a web app running on asp.net is this do able or does any one have advice/opinions. How hard is it to get something like this working on a windows server? Any input would be appreciated. I know I could do this easily in c# and probably should, but I'm looking for any excuse to get Perl running on our servers. That way I can have an excuse for using it on more projects moving forward.

Rolling variable
7 direct replies — Read more / Contribute
by artperl
on Jul 30, 2015 at 09:35
    Dear Perl monks, I would like to seek recommendation on what could be a good solution here... I would like to monitor file count in a specific directory & record the count every hour. I would need to keep that counts somewhere for another calculation but I would like to keep only the last 8 counts, meaning throw away the oldest data & just keep the last 8 records. How can I effectively do this in perl? Thanks much!...
INIT {$SIG{__DIE__} and Getopt::Long
5 direct replies — Read more / Contribute
by demichi
on Jul 29, 2015 at 13:16
    Hi all

    I am normally using the following line to capture the die output into a logfile.

     INIT {$SIG{__DIE__}=sub {LOG_MSG("normal",3,"GENERAL","Script died: $_[0]") and close LOG;}}

    Now I am using also Getopt::Long. I don't want to have a logfile generated if somebody is chosing the wrong parameter. Therefore I let the script die with an usage output.

    Unfortunately if somebody choses a wrong getopt parameter now - I get a log error message because of the INIT-"die" setting as the log file is not opened yet.

    Example:
    G:\development\bin>x.pl -x > 4,GENERAL,Script warning: Unknown option: x print() on unopened filehandle LOG at G:\development\bin\x.pl line 45. + ### Version:2.0.0 NAME xxx > 3,GENERAL,Script died: 1 at G:\development\bin\x.pl line 14. ### > 4,GENERAL,Script warning: print() on unopened filehandle LOG at G:\d +evelopment\bin\x.pl line 45. ### print() on unopened filehandle LOG at G:\development\bin\x.pl line 45. + ### 1 at G:\development\bin\x.pl line 14. ### G:\development\bin>

    Every line marked with "###" at the end I do not want to have as output to STDOUT.

    Do you have an ideas how can fix it? Thanks.

    kind regards de Michi

    Code:
    use strict; use warnings; use Getopt::Long qw(:config no_ignore_case bundling); # Get options / my $VERSION = "2.0.0"; INIT {$SIG{__DIE__}=sub {LOG_MSG("normal",3,"GENERAL","Script died: $_ +[0]") and close LOG;}} INIT {$SIG{__WARN__}=sub {LOG_MSG("normal",4,"GENERAL","Script warning +: $_[0]")}} # Check Flags my $flag_help; my $flag_version; my $flag_config; GetOptions ( 'h|help' => \$flag_help, 'V|VER' => \$flag_version, 'c|config=s' => \$flag_config, ) or die USAGE(); # Check flags and print usage if ($flag_version) { print "Version: $VERSION\n"; exit; } if ($flag_help) { USAGE(); exit; } open(LOG,"> SCRIPTLOG_FILE") or die ("Can't open SCRIPTLOG_FILE: $!\n" +); close LOG; ### subs sub LOG_MSG { my $par_LEVEL = shift (@_); my $par_SEVERITY = shift (@_); my $par_FUNCTION = shift (@_); my @line = @_; print "> $par_SEVERITY,$par_FUNCTION,@line\n"; print LOG "$par_SEVERITY,$par_FUNCTION,@line\n"; } sub USAGE { my ($message)=<<'MESSAGE'; NAME xxx MESSAGE print "Version:${VERSION}\n$message"; }
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 musing on the Monastery: (14)
As of 2015-08-03 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (57 votes), past polls