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

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
combine logentries with Log::log4perl
2 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 03, 2015 at 05:26

    i use different appenders, with different thresholds. i like to aggregate or combine log entries by time or by number of log entries. i played with Log::Log4perl::Appender::Buffer but i had no luck. it buffered the wrong logger or didn't buffered at all or log entries disappeared or got doubled. simply: a mess.

    the only thing i like to achive:

    simply combine multiple log entries into one, big chunk. it's ok that all messages share a timestamp, i don't need a line number or something. just log, what happens, not when and where.

    you might say: concatenate the messages in a string or something like that. but thats off what i need. i don't like to handle a string beside.

    do you know a solution or do i need to write my own composite appender? (which is not my top prio, .= would be easier alternative)

    thank you for your time.
List Context Warn
4 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 02, 2015 at 14:06
    Hi there Monks!
    I am getting warnings in my code as this:
    Name "CGI::LIST_CONTEXT_WARN" used only once: possible typo at

    This is how I start the code, am I using it wrong?
    #!/usr/bin/perl use strict; use warnings; use CGI; use DBI; use DBD::ODBC; use Data::Dumper; use JSON; use HTML::Template; use List::Util qw(sum); $CGI::LIST_CONTEXT_WARN = 0; my $q = CGI->new; ....

    Thanks for looking!
Ping and Linux firewall
3 direct replies — Read more / Contribute
by BrianDStark
on Sep 02, 2015 at 12:14
    I am able to ping manually from a windows platform to a linux platform, but I can't ping within my script using Net::Ping. I'm pretty sure this is because Net::Ping does a deeper transaction. I vaguely remember "fixing" this issue with a big hammer by turning off the firewall on my Linux platform. This was OK, since my script was being used in a local network for my own use. I would like to know the more surgical approach, like what firewall setting will allow my Linux platform to respond to the Pings without disabling the firewall all together. I am using Centos 6 and 7. Thanks!
XML Entity Injection with SOAP::Lite
1 direct reply — Read more / Contribute
by Scheiy
on Sep 02, 2015 at 05:36

    Hey guys. I know u get this all the time but I'm new here so please be patient with me

    I'm trying to get rid of an entity injection problem using Perl/FCGI and SOAP::Lite 0.69. For this I tried to switch the $DO_NOT_USE_XML_PARSER from 0 to 1 within the SOAP::Lite modul. I tested this with a SOAP call from a web service using wget and it worked quiet nice for me.

    Now I'm trying the same thing with a SOAP Client - and it doesn't work. At least not always. The first request always looks fine, but any further request fail with an "500 Internal Server Error".

    My debugging failed completely. The request always looks nice - in the first call as well as in any further calls - but the response suddenly fails with a "Application failed during request deserialization: Unresolved prefix 'soap' for attribute 'soap:Envelope'" message. What bugs me the most is the different log messages in the error log and the console. The error log always prints out the following (I tried to format the output for u guys to make it easier to read):

    mod_fcgid: stderr: SOAP::Lite - deserialize - start decoding: <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="" xmlns:soapenc="" xmlns:xsd="" soap:encodingStyle="" xmlns:soap=""> <soap:Body> <ping xmlns="TRONServer"> <c-gensym3 xsi:type="xsd:int">42</c-gensym3> </ping> </soap:Body> </soap:Envelope>
    For the output on the console screen i get two different outputs. For the first (working) try I get
    SOAP::Lite - deserialize - start decoding: <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="" xmlns:soap="" xmlns:xsi="" xmlns:SOAP-ENC="" xmlns:tron="" xmlns:xsd=""> <soap:Body> <pingResponse xmlns="TRONServer"> <numerPlusOne xsi:type="xsd:int">43</numerPlusOne> </pingResponse> </soap:Body> </soap:Envelope>
    while for the second and any other tries it prints out
    SOAP::Lite - SOAP::Parser - start decoding: <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="" xmlns:soap="" xmlns:xsi="" xmlns:SOAP-ENC="" xmlns:tron="" xmlns:xsd=""> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Application failed during request deserialization: +Unresolved prefix 'soap' for attribute 'soap:Envelope' </faultstring> </soap:Fault> </soap:Body> </soap:Envelope>
    Notice that in both cases I use the same STDERR method within the SOAP::Lite module:
    print STDERR "SOAP::Lite - deserialize - start decoding: $_[0]\n"; my $parsed = $self->decode($_[0]);
    For the first run this runs through nicely. For any further runs the call seems to crash during the decode process. The decode sub looks like the following:
    sub decode { SOAP::Trace::trace('()'); my $self = shift; $self->parser->setHandlers( Final => sub { shift; $self->final(@_) }, Start => sub { shift; $self->start(@_) }, End => sub { shift; $self->end(@_) }, Char => sub { shift; $self->char(@_) }, ExternEnt => sub { shift; die "External entity (pointing to '$_[1] +') is not allowed" }, ); # my $parsed = $self->parser->parse($_[0]); # return $parsed; # my $ret = undef; eval { $ret = $self->parser->parse($_[0]); }; if ($@) { print STDERR "SOAP::Lite - SOAP::Parser - Error Message: $@\n"; $self->final; # Clean up in the event of an error die $@; # Pass back the error } return $ret; }
    The eval part crashes with the following exit message:
    SOAP::Lite - SOAP::Parser - Error Message: Can't use string ("1") as a +n ARRAY ref while "strict refs" in use at (re_eval 159) line 1.
    Up to this point I couldn't figure out why this is the case and where it crash.

    I think I found the problem. I dogged into the XML::Parser:Lite modul a little deeper and stumbled about a compile sub that did not make much sense for me:

    sub compile { local $^W; # try regexp as it should be, apply patch if doesn't work foreach (regexp(), regexp('??')) { eval qq{sub parse_re { use re "eval"; 1 while \$_[0] =~ m{$_}go }; + 1} or die; last if eval { parse_re('<foo>bar</foo>'); 1 } }; *compile = sub {}; }
    Especially with the parse_re sub it didn't make much sense with me. So I replaced that sub with the XML::Parser::Lite parse_re sub I found in the 0.721 Version of the Lite Modul I found on CPAN - and now it works. I probably have some more testing to do to verify that but for now it seems to work. Thanks for listening :)

Trying to capture a value from a list of values
3 direct replies — Read more / Contribute
by parthodas
on Sep 02, 2015 at 04:48
    I'm trying to capture the first value from a list of values. My script has multiple sub sections. In one, we have declared global variables and then as per requirement we are using them. As per my requirement, I'm calling linux servers(which has 4 values), and try to capture the first value. It is not coming as expected.
    @mylnxsrvrs = split(',', $myhash{SBLLNXSRVRHOSTS}); @mywinsrvrs = split(',', $myhash{SBLWINSRVRHOSTS}); @mysblroot = split(',', $myhash{SIEBELROOT}); @mysblsrvrpath = (',',$myhash{SBLSRVRPATH}); foreach $a (@mylnxsrvrs) {my $lnxsrvr = "$a"; printf "$a $lnxsrvr\n\n";} printf "$lnxsrvr\n"; printf "@mylnxsrvrs";

    The output looks like this --
    dvapoms1 dvapoms1
    dvapoms2 dvapoms2

    dvapoms1 dvapoms2

    If I'm trying to assign the value, it is giving junk result --
    my $lnxsrvrs = "@mylnxsrvrs"; printf "$lnxsrvrs";
    The output shows -- 1
No recursion depth limit?
5 direct replies — Read more / Contribute
by Yary
on Sep 01, 2015 at 21:28
    I have this memory of Perl limiting how deep subroutine recursion could go, but the following test suggests not:
    perl -E 'sub f{say $_[0] unless $_[0] % 10000;exit if $_[0] > 30000;f( +$_[0]+1)};f(1)'

    on perl 5.12 and 5.20, on windows and NetBSD, they both run (and without apparent limit, if you remove the "exit")

    I got bit when debugging a recursive sub, and my perl process hard-froze my Windows 7 machine. The mouse moved but nothing else worked, not ctrl-alt-del, not "Fn-Sleep". I waited about 10 minutes, thinking it would run out of memory and exit, but the machine just stayed frozen :-(

    Just curious if there was a recursion limit, and if so, when was it lifted?

    Next day addendum - Thanks for all the replies! I've encountered the runtime warning, and the regexp recursion limit, and the debugger warnings all in the past, and I must have confabulated them. You all got ++ votes from me for your reminders.

Parsing text string in Perl
4 direct replies — Read more / Contribute
by gbwien
on Sep 01, 2015 at 17:48

    I am trying to get back into Perl and I have a question regarding how best to parse the following

    I have a file which contains many of the following entries

    Time: 1/9/2015-09:01:43.010 Protocol: SMPP ESME: ehttp_rknoe Direction: Outgoing From: To: PDU Type: Full PDU PDU Length: 16 PDU Data: 00000010800000040000005800029a92 Decode Error 0x00000000 Decoded PDU: [ smpp hdr 16 octets ] 00000000: 00 00 00 10 command_length: 16 00000004: 80 00 00 04 command_id: 0x80000004 submit_sm_re +sp 00000008: 00 00 00 58 command_status: 0x00000058 ESME_RTH +ROTTLED 0000000C: 00 02 9A 92 sequence_number: 170642

    I want to parse the complete file in perl and print out time and only those entries that have ESME_RTHROTTLED.

    The file may contain many other entries but I only want to print out this entry

    Thanks tom
Problems with PDF::API2 and TextBlock
1 direct reply — Read more / Contribute
by dougconran
on Sep 01, 2015 at 17:41
    I have an application that uses PDF::API2 (amogst other things to display jpg images) and PDF::TextBlock which has been running without problems on perl5.10.1. However I've just (foolishly, probably) upgraded my server and perl to v5.22.0. I've installed the relevant modules but I'm getting some really weird behaviour. Sometimes the pdf document will print with data and image but as often as not it just prints the initial blank pdf page (which I load from a base pdf doc). After exhaustive testing it would seem that $pdf->image_jpeg is one culprit the other being the TextBlock ->apply method. As far as I'm aware the problem areas work fine in another similar program and sometimes in this one. What's going on and does anyone have any idea how to fix it?
Processing spreadsheet with some cells in ASCII, other cells in UTF-8
3 direct replies — Read more / Contribute
by Amphiaraus
on Sep 01, 2015 at 16:43

    I am writing a Perl program which takes input from a column in an Excel spreadsheet listing names of European cars. This column is named "MenuList". The names of European cars often contain letters with symbols above them that are not seen in English, and which must be encoded in UTF-8 (Examples: , , ). Other cells in the same column lack these foreign symbols and are encoded in ASCII. I am writing out the contents of this column to an *.ini file.

    I am finding that with the code shown below, the car names in ASCII are being written out to the *.ini file without problems, but the car names with foreign symbols - encoded in UTF-8 - are garbled in the *.ini file. These garbled strings are accompanied by the error message "Wide character in print"

    Is there a way to read input from an Excel spreadsheet with mixed encoding (some cells in UTF-8, other cells in ASCII), and write contents of these cells to an *.ini file, with no garbled output in the *.ini from the cells that contained UTF-8 encoding?"

    chomp $menuList[$i]; $decodedMenuList = decode("utf8",$menuList[$i]); $cfg_baselicense->newval($partNumList[$i],"MenuSelection",$decod +edMenuList); $cfg_baselicense->RewriteConfig();
getting content of an https website
3 direct replies — Read more / Contribute
by Datz_cozee75
on Aug 31, 2015 at 18:49

    I'm having a facebook discussion with a friend from high school who claimed that the word 'enemy' appeared on a webpage, and I wanted to prove that he was making it up and thought to do so with perl. I seem to be unable to get the content of the page and thought I'd ask for a work-around here:

    use strict; use warnings; use feature 'say'; use LWP::Simple; my $url = ''; my $content = get $url; die "Couldn't get $url" unless defined $content; if($content =~ m/enemy/i) { say "enemy found"; } else say $content; }


    Couldn't get  at line 8.

    I suspect that my problem is that https is different than http, but I see no work-around on cpan for LWP::Simple. Am I using the right tool? If so, how do I use it correctly? Thanks for your comment.

DBI/Oracle Nested SELECT query
3 direct replies — Read more / Contribute
by terroirman
on Aug 31, 2015 at 17:45

    I've been looking all around without finding. Here's my question : is this possible to do a nested query with DBI/oracle ?

    Here's my query :


    This is executed instantly in my Oracle client (toad). But in a script, that just hangs there forever. Basically, it doesn't get to the fetchall_arrayref statement.

    $odstthandle = $dbttods->prepare($qry) or die $dbttods->errstr; $odstthandle->execute() or die $odstthandle->errstr; $billets = $odstthandle->fetchall_arrayref or die $odstthandle->errstr +;

    Is that even possible to do ? If so any way to troubleshoot whats taking so long ? If not, any alternative than DBI ?

    Thanks for your time !

exit this way
4 direct replies — Read more / Contribute
by ExReg
on Aug 31, 2015 at 17:29
    I am adding several perl scripts and modules to an existing set of perl tools. When they looked over my latest script, they said that I should have an exit statement at the end, before all the subs. I do not see the need for exit if the script completes normally. Comments?
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 meditating upon the Monastery: (6)
As of 2015-09-04 04:58 GMT
Find Nodes?
    Voting Booth?

    My preferred temperature scale is:

    Results (130 votes), past polls