Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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.

Quests
poll ideas quest 2020
Starts at: Jan 01, 2020 at 00:00
Ends at: Dec 31, 2020 at 23:59
Current Status: Active
12 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
Tau Station Perl MMORPG Kickstarter Launched
on Oct 05, 2020 at 13:21
3 replies by Ovid

    There's a song by Shaggy, "It wasn't me", that is running through my head. If you're familiar with it, it's somehow both catchy and vile. I've had ex partners describe me that way.

    The song is running through my head because I'm not the one who accidentally launched the Tau Station Kickstarter several days early. But it's done.

    And they won't let us restart it.

    So maybe it's not our intended launch window. Maybe we weren't ready. But we're owning this. We're making this happen.

    Please help support the world's first Biblio-RPG. It's a massive, immersive, narrative sci-fi MMO. And it's over 400,000 lines of Perl. Let's show the world what Perl can do.

    Even if you don't want to join in, please share this with everyone!

    Here's the link to the Kickstarter.

    And here's a link to the game. It's free to play and runs in any relatively modern browser, so you won't need to download anything or spend any money.

perldoc.perl.org usable again
on Oct 01, 2020 at 05:12
2 replies by hippo
Supplications
Perl Zlib last block
1 direct reply — Read more / Contribute
by Kroning
on Oct 26, 2020 at 07:36

    Hi!

    I have some packet from app that looks like "ec bd ... 00 00 ff ff" which I am trying to decode.

    From what I have found, it looks like "00 00 ff ff" is a Z_SYNC_FLUSH of deflate (zlib).

    I tried to reproduce it on Compress::Raw::Zlib, Compress::Zlib and some others. But the ending pattern was "00 ff 00 ff". Am I missing something?

    #!/usr/local/bin/perl use Compress::Zlib ; my $x = deflateInit() or die "Cannot create a deflation stream\n" ; ($output, $status) = $x->deflate('text') ; ($output, $status) = $x->flush(Z_SYNC_FLUSH) ; $output =~ s/(.)/sprintf '%04x', ord $1/seg; print "output=$output\n";
    output=002a004900ad0028000100000000000000ff00ff00000000000000ff00ff
Applying regex to each line in a record.
9 direct replies — Read more / Contribute
by pritesh_ugrankar
on Oct 24, 2020 at 14:40

    Hi Monks,

    Even after multiple attempts, I am at a total loss of how the "m" and "s" works for regex. I have a file like this:

    first: this:that here:there when:what how:where now:later second: this:that here:there when:what how:where now:later

    Please note that in the example, "this:that", "here:there", etc are repeated, but that's not the case with the actual record I am working on. I am trying to write a script that will create a hash of hashes such that I get a hash with a key "first" and its value will be a key value pair such that the key will be "this" and value will be "that", key will "here" and value will be "there", and so on and so forth. But even before I reach there, I need to ensure that I write the correct regex. So, I tried to write a regex that will skip the line if it contains "first" or "second". Of course if the regex works, I can then capture the part and make that as a hashkey, but that's much later.

    I've tried the following, but it does not work. And I am pretty sure it's because my utter failure to understand how "m" and "s" work.

    use strict; use warnings; use Data::Dumper; my $file = "new_testfile.txt"; my $testhashref; open (my $fh, "<",$file) or die "Can't open open file $file:$!"; { local $/ = ""; while (my @records = <$fh>) { foreach my $line (@records) { next if $line =~ /^[a-z]+:$/m; print "$line"; } } }

    I tried using "s" instead of "m", but when I run the script, it does not read anything.

    pritesh@pavilion:~/perlscripts$ perl test.pl pritesh@pavilion:~/perlscripts$

    If I remove the next if $line =~ /^[a-z]+:$/m;, I get the whole file like so:

    pritesh@pavilion:~/perlscripts$ perl test.pl first: this:that here:there when:what how:where now:later second: this:that here:there when:what how:where now:later

    So at least I know it's reading the records right. I will be thankful if you could help me with this one.

int() function
6 direct replies — Read more / Contribute
by geoperl
on Oct 24, 2020 at 06:45

    Hi Monks

    I came across with a strange result when I'm using int() function. For example,

    my $x1 = (1.15*170)+0.50; my $x2 = int($x1); print "Number is: $x1, Integer part is: $x2";

    It prints "Number is: 196, Integer part is: 195", but I would expect $x2 to be 196

    But when I am using different numbers I am getting the correct results. For example,

    my $x1 = (1.15*150)+0.50; my $x2 = int($x1); print "\nNumber is: $x1, Integer part is: $x2";
    my $x1 = (1.15*30)+0.50; my $x2 = int($x1); print "\nNumber is: $x1, Integer part is: $x2";

    Can anybody guess what goes wrong with the first one, what goes wrong when I'm using the number 170? At least, I would expect either all results be correct or all results be wrong, but not just one be wrong.

    Using int(sprintf("%.2f",$x1)) fixes the error but this is not the issue.

Soap Call fails
1 direct reply — Read more / Contribute
by PerlMASA
on Oct 23, 2020 at 23:24

    I am trying to call a Soap Webservice.I have to pass the name of a Code table (for eg STATE_CODES) and it returns key value pair like NY - New york, DE-Delaware etc.

    #!/usr/local/bin/perl use strict; use warnings; use Data::Dumper qw<Dumper>; #use SOAP::Lite trace=>'all'; use SOAP::Lite +trace =>'debug'; #use SOAP::Lite; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1; #my $wsdl = 'https://dev1:2001/ACTS?wsdl'; my $endpoint = 'https://qa1:2001/ACTS'; my $wsdl = 'HTTPS://QA1:2001/ACTS?wsdl'; my $method_name = 'impl:getCodes'; my $uri = 'http://impl.webservice.acts.ito.aoc.nj'; my $ns = 'http://impl.webservice.acts.ito.aoc.nj'; my $client = SOAP::Lite->new( proxy=>$endpoint, service=>$wsdl, readable=>1 ); $client->outputxml(1); $client->envprefix('soapenv'); $client->ns($uri,'impl'); $client->outputxml('true'); my @param; push @param, SOAP::Data->name("codeTable"=>'STATE_CODES'); my $soapResp = $client->call($method_name,@param); print $soapResp; print "\n";

    output is as below
    root@np1 ~# perl /test/soaptest6.pl
    SOAP::Transport::HTTP::Client::send_receive: POST https://qa1:2001/ACTS HTTP/1.1
    Accept: text/xml
    Accept: multipart/*
    Accept: application/soap
    Content-Length: 580
    Content-Type: text/xml; charset=utf-8
    SOAPAction: "http://impl.webservice.acts.ito.aoc.nj#getCodes"

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:impl="http://impl.webservice.acts.ito.aoc.nj"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <impl:getCodes>
    <codeTable xsi:type="xsd:string">STATE_CODES</codeTable>
    </impl:getCodes>
    </soapenv:Body>
    </soapenv:Envelope>
    SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Error
    Connection: close
    Content-Type: text/xml; charset=utf-8
    Client-Date: Sat, 24 Oct 2020 02:46:04 GMT
    Client-Peer: 192.168.248.33:2001
    Client-Response-Num: 1
    Client-SSL-Cert-Issuer: /CN=qa1
    Client-SSL-Cert-Subject: /CN=qa1
    Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384
    Client-SSL-Socket-Class: IO::Socket::SSL
    Client-SSL-Warning: Peer certificate not verified
    X-Backside-Transport: FAIL FAIL

    <?xml version='1.0' ?>
    <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Body>
    <env:Fault>
    <faultcode>env:Client</faultcode>
    <faultstring>Internal Error</faultstring>
    </env:Fault>
    </env:Body>
    </env:Envelope>
    <?xml version='1.0' ?>
    <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Body>
    <env:Fault>
    <faultcode>env:Client</faultcode>
    <faultstring>Internal Error</faultstring>
    </env:Fault>
    </env:Body>
    </env:Envelope>

    The soap request kind of looks good, but it gives error. I pasted the soap request into SOAPUI from the soapActionand it worked.

    Why is my soap request resulting in failure. is it because of some certificate issue. i believe i have asked the code to skip certificate validation and Client-SSL-Warning: Peer certificate not verified in output above is just a warning and can be ignored

    Is the line between getCodes" and <?xml version="1.0"... in soapAction causing failure. The request failed in SOAPUI if I added a line before the <?xml version="1.0"...

    if it helps, the soap webservice is a java application on websphere and it is being accessed by perl through datapower.

select RBITS,WBITS,EBITS,TIMEOUT. The meaning of all the *BITS
2 direct replies — Read more / Contribute
by igoryonya
on Oct 22, 2020 at 20:38
    I am reading documentation on select command and I can't figure out, what these RBITS,WBITS,EBITS mean.

    Well, I came to guess, that probably, RBITS - means Read Bits, WBITS - Write Bits, but what about EBITS, then?
    What does this construct mean? What is it used for? Manual doesn't explain anything. Just throws these:

    select RBITS,WBITS,EBITS,TIMEOUT
    my ($nfound, $timeleft) = select(my $rout = $rin, my $wout = $win, my $eout = $ein, $timeout);
    
    without any explanation.
Any reason to use the Paws module over aws cli commands in perl script?
5 direct replies — Read more / Contribute
by nysus
on Oct 21, 2020 at 09:25

    What are the arguments for using the Paws module instead of just embedding commands like `aws ec2 run-isntances --image-id ....` into my perl script? I feel dirty just executing command line commands in my perl script and it doesn't feel very professional, but what's the harm, really?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

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 about the Monastery: (8)
As of 2020-10-27 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (257 votes). Check out past polls.

    Notices?