Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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
Apache::RequestNotes in mod_perl 2.0
No replies — Read more | Post response
by ait
on Aug 29, 2014 at 10:54


    I noticed that Apache::RequestNotes doesn't seem to be available for Apache2 so I am guessing that this functionality was incorporated in mod_perl 2.0 natively?

    If so, would someone kindly point me to an example on how to do this exact same thing with mod_perl 2?

    I need something very early in the request that parses form data and then make it avail to the rest of the request. My current solution involves a PerlTransHandler that slurps the content, parses it and saves it to notes. Then I have to re-inject the raw content back with a PerlInputFilterHandler so it's avail for the rest of the request chain.

    I hate re-inventing the wheel and I think something like Apache::RequestNotes would really be more elegant for what I'm trying to do.

    Many thanks in advance!

Sending Email with Dancer::Plugin::Email
No replies — Read more | Post response
by tushardave26
on Aug 28, 2014 at 23:04

    Hello Folks,

    Currently, I am developing Dancer web application. As part of my application, I would like to send email to users. I am referring Dancer::plugin::Email manual to accomplish the task. I adapted the code form the manual. But some how my code is neither working nor producing any error. Below find my code:

    use Dancer ':syntax'; use Dancer::Plugin::Email; use Try::Tiny; post '/ednContacts' => sub { try { email { from => params->{'email'}, to => '', subject => 'Contacting for EDN Web site', body => params->{'message'} }; } catch { error "Could not send email: $_"; }; };

    FYI, I am using MAC OSX 10.9.4. And running my application on localhost:3000

    Can some one point out any problem in my code?


Default named params with an embedded hash
1 direct reply — Read more / Contribute
by neilwatson
on Aug 28, 2014 at 15:12


    I'm trying to use named parameters with default values. For a normal hash this is simple, but I have a more complex data structure.
    #!/usr/bin/perl use strict; use warnings; use feature 'say'; use Data::Dumper; my %valid_inputs = ( one => 1, two => 2 ); validate( valid_inputs => \%valid_inputs, max_record_length => 72, ); sub validate { my %params = ( valid_inputs => { one => 'one', two => 'two', three => 'three', four => 'four', }, max_record_length => 24, @_, ); my $valid_inputs = $params{valid_inputs}; say '@_ ['.Dumper( \@_ ).']'; say '%params ['.Dumper( \%params ).']'; say '%valid_inputs ['.Dumper( \%valid_inputs ).']'; } #EOF Output: @_ [$VAR1 = [ 'valid_inputs', { 'two' => 2, 'one' => 1 }, 'max_record_length', 72 ]; ] %params [$VAR1 = { 'valid_inputs' => { 'two' => 2, 'one' => 1 }, 'max_record_length' => 72 }; ] %valid_inputs [$VAR1 = { 'two' => 2, 'one' => 1 }; ]

    Because valid_inputs is a reference it over writes the defaults completely rather than just the same keys as with max_record_length. If make valid_inputs not a refence the final complete hash is scrambled and flat. Is there an elegant solution?

    Neil Watson

How to encode after using HTML::Strip
1 direct reply — Read more / Contribute
by myfrndjk
on Aug 28, 2014 at 14:36

    Hi I am trying to encode the html page using cp1252 since it has lot of special characters like € and £ pounds but when i try to save those contents after using HTML::strip .All were displayed as junk values.I tried to encode using cp1252 but its not working.Please help me to fix the issue.

    use strict; use warnings; use HTML::TreeBuilder::XPath; use LWP::UserAgent ; use HTTP::Request ; use HTML::Entities; use HTML::Strip; use encoding "cp1252"; open (OUT, '>:encoding(cp1252)',"/home/local/ANT/jeyakuma/Desktop/test +.html"); my $URL = ' +aspx'; my $agent = LWP::UserAgent->new(agent => "Mozilla/5.0"); my $request = HTTP::Request->new(GET=> $URL); my $response = $agent->request($request); # Check the outcome of the response if ($response->is_success) { my $xp = HTML::TreeBuilder::XPath->new_from_content($response->decoded +_content); my $raw_html = $xp->findnodes_as_string('//div[@class="faq_text"]/p/st +rong/u[contains(.,\'spedizione Standard \')]'); my $hs = HTML::Strip->new(); my $clean_text = $hs->parse( $raw_html ); $hs->eof; print OUT $clean_text; } elsif ($response->is_error) { print "Error:$URL\n"; print $response->error_as_HTML; }

    Expected output :£ 60/

    current output : £ 60/â‚

Cursor keys with Tk::Hlist goes wrong
1 direct reply — Read more / Contribute
by luke67m
on Aug 28, 2014 at 12:45
    Hi monks. I'm trying to use Tk::Hlist in a panel for file selection. I'm trying to make the panel usable both under linux and windows. I'm a newby. The hlist has 3 Columns. Here the problem : Under linux, if I define the first column with itemCreate, the cursor keys up and down works in unpredictable ways : Up sometimes goes down and down sometimes goes up. Under windows everything seems to work. Here a sample of my code
    ########################################################### #this not work my $e = $tree->add( $dir ); $tree->itemCreate ($e, 0, -itemtype => 'imagetext', -text => $text, -image => $tree->Getimage("folder"), -style=> $Col0StyleA ); #this not work ########################################################### #this work # my $e = $tree->add( $dir , -text => $text, -image => $tree->Geti +mage("folder"), # ); #this work ###########################################################
    I'm using winxp strawberry 5.18 and lubuntu 14.4 . Feel free to ask for full source, I can publish it on sourceforge
Get variables from txt file
3 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 28, 2014 at 12:15


    I have written a perl script but I don't know how to get the variables from a txt file. Actually, I can read the txt file in hash and get the variables but I have a small issue. In the txt file I have some paths that include variables.

    The txt file with the variables looks like:

    V1=/home/user V2=$V1/test V3=$V2/file.txt

    I read the lines using:

    Read variables open my $vars, '<:utf8', "$Bin/vars.txt" or die $! ; while (<$vars>) { chomp; my ($key, $value) = split(/=/, $_); $vars{$key} = $value; } my $V1 = $vars{'V1'}; my $V2 = $vars{'V2'}; my $V3 = $vars{'V3'}; print "$V1\n"; print "$V2\n"; print "$V3\n"; close ($vars);

    The result that I get is:

    /home/user /$V1/test /$V2/file.txt

    but I want

    /home/user /home/user/test /home/user/test/file.txt

    I would appreciate any help.

Tcl module install issues
No replies — Read more | Post response
by CarolinaPerler
on Aug 28, 2014 at 10:19

    Trying to install the Tcl/Tk modules to do a GUI on AIX5.3. I have successfully built the Tcl libraries from source. And, I've been able to install the RPM packages via the AIX linux tools. However, I cannot get things combed straight.

    perl ./ - works.
    make appears to work.
    make test fails spectacularly. Since won't load, all tests fail.

    My suspicion is that there is a 32 vs 64 bit tangle. When I built the Tcl libraries from source I used --enable-64bit. As the build ran, I noticed a warning stating 64bit was not supported on AIX, and it reverted back to 32. The libs built and I can crankup tclsh. But, I'm suspicious that the 64bit Perl install is choking on the 32bit libraries.

    Any feedback about this specific issue would be appreciated. Also, any ideas on the wider process of getting Tcl/Tk and associated Perl modules installed on AIX5.3 would be appreciated.

    root@host:/opt/perl-5.14.4/downloads/modules/Tkx/Tcl-1.02# perl514 Mak +efile.PL LIBS = -Ltcl-core/aix -ltclstub8.4 INC = -Itcl-core/include DEFINE = -DUSE_TCL_STUBS Checking if your kit is complete... Looks good Warning: -Ltcl-core/aix changed to -L/opt/perl-5.14.4/downloads/module +s/Tkx/Tcl-1.02/tcl-core/aix Generating a Unix-style Makefile Writing Makefile for Tcl Writing MYMETA.yml and MYMETA.json root@host:/opt/perl-5.14.4/downloads/modules/Tkx/Tcl-1.02# make cp blib/lib/ /usr/bin/perl514 -e 'use ExtUtils::Mksymlists; Mksymlists("NA +ME" => "Tcl", "DL_FUNCS" => { }, "FUNCLIST" => [], "DL_VARS" => []); +' Running Mkbootstrap for Tcl () chmod 644 /usr/bin/perl514 /opt/perl-5.14.4/lib/5.14.4/ExtUtils/xsubpp +-typemap /opt/perl-5.14.4/lib/5.14.4/ExtUtils/typemap -typemap typema +p Tcl.xs > Tcl.xsc && mv Tcl.xsc Tcl.c Please specify prototyping behavior for Tcl.xs (see perlxs manual) gcc -maix64 -maix64 -c -Itcl-core/include -D_THREAD_SAFE -D_ +ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -DNEE +D_PTHREAD_INIT -fno-strict-aliasing -pipe -I/usr/local/include -maix6 +4 -DUSE_64_BIT_ALL -O -DVERSION=\"1.02\" -DXS_VERSION=\"1.02\" " +-I/opt/perl-5.14.4/lib/5.14.4/aix-thread-multi-64all/CORE" -DUSE_TCL +_STUBS Tcl.c rm -f blib/arch/auto/Tcl/ gcc -maix64 -maix64 -Wl,-b64 -Wl,-bhalt:4 -Wl,-G -Wl,-bI:/opt +/perl-5.14.4/lib/5.14.4/aix-thread-multi-64all/CORE/perl.exp -Wl,-bE: +Tcl.exp -Wl,-bnoentry -lpthreads -lc -lm -L/usr/local/lib Tcl.o -o b +lib/arch/auto/Tcl/ -L/opt/perl-5.14.4/downloads/module +s/Tkx/Tcl-1.02/tcl-core/aix -ltclstub8.4 chmod 755 blib/arch/auto/Tcl/ /usr/bin/perl514 -MExtUtils::Command::MM -e 'cp_nonempty' -- blib/arch/auto/Tcl/ 644 Manifying blib/man3/Tcl.3 root@host:/opt/perl-5.14.4/downloads/modules/Tkx/Tcl-1.02# make test Running Mkbootstrap for Tcl () chmod 644 PERL_DL_NONLAZY=1 /usr/bin/perl514 "-MExtUtils::Command::MM" " +-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0 +, 'blib/lib', 'blib/arch')" t/*.t t/call.t ........... Can't load '/opt/perl-5.14.4/downloads/modules/Tk +x/Tcl-1.02/blib/arch/auto/Tcl/' for module Tcl: rtld: 0712-001 +Symbol Tcl_InitStubs was referenced from module /opt/perl-5.14.4/downloads/modules/Tkx/Tcl-1.02/blib +/arch/auto/Tcl/, but a runtime definition of the symbol was not found. rtld: 0712-001 Symbol tclStubsPtr was referenced from module /opt/perl-5.14.4/downloads/modules/Tkx/Tcl-1.02/blib +/arch/auto/Tcl/, but a runtime definition of the symbol was not found. rtld: 0712-002 fatal error: exiting. at /opt/perl-5.14.4/lib/5.14.4/ai +x-thread-multi-64all/ line 190. at t/call.t line 6 Compilation failed in require at t/call.t line 6. BEGIN failed--compilation aborted at t/call.t line 6. Undefined subroutine &Tcl::_Finalize called at /opt/perl-5.14.4/downlo +ads/modules/Tkx/Tcl-1.02/blib/lib/ line 422. END failed--call queue aborted at t/call.t line 6. t/call.t ........... Dubious, test returned 22 (wstat 5632, 0x1600)
Sending module output to STDOUT in test
5 direct replies — Read more / Contribute
by loris
on Aug 28, 2014 at 08:21

    Dear Monks,

    I have a test using Test::More which is failing. I would like to debug the relevant subroutine in my module by inserting a print to see what is going on.

    How do can I see the output when I run the test with, say, prove?



Error while reading .xls file
1 direct reply — Read more / Contribute
by a.alandkar
on Aug 28, 2014 at 06:53

    Hello all, I am using strawberry perl. Facing some issues.

    #! usr/bin/perl -w #use,strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; my $workbook; my @labels = ('Parameter_Name','Parameter_Index','Storage_Class','Data +_Type','min_range_value','max_range_value','default_value','test_valu +e','mode_for_write','access_rights','view1','view2','view3','view4'); $workbook = Spreadsheet::WriteExcel->new('perl.xls'); $worksheet = $workbook->add_worksheet(); for($for=0;$for<13;$for++) { $worksheet->write(0,$for,$labels[$for]); # print($for); # print($labels[$for]); } &get_max_row_col(); sub get_max_row_col() { my $parser = Spreadsheet::ParseExcel->new(); my $workbook1 = $parser->parse('perl.xls'); for my $worksheet ( $workbook1->worksheet(0) ) { my ( $row_min, $row_max ) = $worksheet->row_range(); # + Find out the worksheet ranges my ( $col_min, $col_max ) = $worksheet->col_range(); print ("max_rows = $row_max \n"); print ("max_cols = $col_max \n"); } }

    when i compile this code it gives me an error saying (C:\Users\Ambar.Alandkar\Desktop\Ambar\Perl-Test>perl Can't call method "worksheet" on an undefined value at line 29.) but when i run the get_max_row_col() subroutine code making a separate file it works well without any error. Is there anything missing or wrong in implementation.? Please help.

mqseries_1.34 Makefile loop
1 direct reply — Read more / Contribute
by itc
on Aug 28, 2014 at 06:40

    I am looking for help with a problem installing the MQseries-1.34 Perl API.

    I had successfully installed it in our sandpit server, then moved onto our development server and had an issue with the Makefile resulting in a looping zombie process requiring the server to be rebooted.

    I then had the sandpit server rebuilt to mirror development and have reproduced the issue on the sandpit server.

    After installing required pre-requisites, here is what I see for the Makefile….

    $ sudo perl Makefile.PL verbose Password: Checking if your kit is complete... Looks good ABSTRACT => q[Interface to IBM's MQSeries Product] AUTHOR => q[MQ Engineering Group <>] NAME => q[MQSeries] PREREQ_PM => { Params::Validate=>q[1.00], Test::Simple=>q[0.62], Con +vert::EBCDIC=>q[0.06], Test::Pod=>q[1.20] } VERSION_FROM => q[] Using PERL=/usr/bin/perl

    ….it does not respond beyond this point and continues looping indefinitely. Additional info below

    AIX version

    $ oslevel -s 6100-08-03-1339

    MQ version

    (0)mqm@rs6stech02:/home/mqm: dspmqver Name: WebSphere MQ Version: CMVC level: p701-107-111117 BuildType: IKAP - (Production)

    Perl installation

    $ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=aix, osvers=, archname=aix-thread-multi uname='aix akash79 3 5 00011a85d600 ' config_args='-desr -Dinstallprefix=/usr/opt/perl5 -Dprefix=/usr/op +t/perl5 -Dcc=xlc_r -Duseshrplib -Dusethreads' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc_r', ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURC +E -qmaxmem=-1 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT - +q32 -D_LARGE_FILES -qlonglong', optimize='-O', cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem= +-1 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='ld', ldflags =' -brtl -bdynamic -b32' libpth=/lib /usr/lib /usr/ccs/lib libs=-lbind -lnsl -lgdbm -ldbm -ldb -ldl -lld -lm -lcrypt -lpthrea +ds -lc -lbsd perllibs=-lbind -lnsl -ldl -lld -lm -lcrypt -lpthreads -lc -lbsd libc=, so=a, useshrplib=true, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -bE:/usr/ +opt/perl5/lib/5.8.8/aix-thread-multi/CORE/perl.exp' cccdlflags=' ', lddlflags='-bhalt:4 -bexpall -G -bnoentry -lpthrea +ds -lc' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under aix Compiled at Jun 2 2009 16:11:40 @INC: /usr/opt/perl5/lib/5.8.8/aix-thread-multi /usr/opt/perl5/lib/5.8.8 /usr/opt/perl5/lib/site_perl/5.8.8/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.8 /usr/opt/perl5/lib/site_perl

    Can you please help me identify where I have gone wrong or offer me a workaround ?

Can you offer me some tips on this module?
1 direct reply — Read more / Contribute
by Anonymous Monk
on Aug 27, 2014 at 11:25
    Dear friends,
    I am trying to use the following module in a project of mine...

    It works fine, but I was wondering, is there a way that I can tilt the bars to have an angle, instead of being vertical?
    My code, based on the module, which uses GD-graph, is the following:
    use DrawTransmembrane; $topology_final = 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIII0IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIMMMMMMMMMOOOOO +OOOOOOOOOOMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIIIIIMMMM +MMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIMMMMMMMMMMMOOOO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOM +MMMMMMMMMMIIIMMMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMM +MMMMMIIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIMMM +MMMMMMMMOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOO +OOOOOMMMMMMMMMMMIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMM'; @total_top = (); if($topology_final=~/M/) { while ($topology_final =~/(.)\1*/g) { if ($1 eq "M") { my $start_TM = $-[0] + 1; my $end_TM = $+[0]; push @total_top, $start_TM; push @total_top, $end_TM; } } my $image = DrawTransmembrane->new ( -title=>"topology prediction image", -n_terminal=>'in', -topology=>\@total_top, -bold_helices=> 1, -bold_labels=>1, -text_offset=>-25, -helix_label=>'b', -outside_label=>'Extracellular', -inside_label=>'Periplasm', -membrane_label=>'Membrane', -helix_width=>30, -vertical_padding=>150, -horizontal_padding=>120, -n_terminal_offset=>50, -n_terminal_height=>220, -c_terminal_offset=>30, -c_terminal_height=>220, -helix_label=>'Sheet', -colour_scheme=>'yellow' ); open (OUTPUT, '>', 'test.png'); binmode OUTPUT; print OUTPUT $image->png; close (OUTPUT); }

    Any tips would be greatly appreciated... The goal should be to tilt the bars a bit, like, e.g. in:
Setting syslog layout with log4perl
1 direct reply — Read more / Contribute
by neilwatson
on Aug 27, 2014 at 10:52


    This is my first dive in log4perl. I'm trying to configure for syslog, but I get the error ERROR: trying to set layout for SYSLOG to '%-5p %C - %m%n'. What is the correct way to configure the layout?

    log4perl.rootLogger=DEBUG, SYSLOG log4perl.appender.SYSLOG = Log::Dispatch::Syslog log4perl.appender.SYSLOG.min_level = debug log4perl.appender.SYSLOG.ident = log4perl.appender.SYSLOG.facility = daemon log4perl.appender.SYSLOG.layout = %-5p %C - %m%n

    Neil Watson

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2014-08-29 17:10 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (283 votes), past polls