free欧美高清猪马牛俄罗斯
Don't ask to ask, just ask
 
PerlMonks  

The Monastery Gates

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

free欧美高清猪马牛俄罗斯

Donations gladly accepted

    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
    8 repliesby pollsters
      First, read How do I create a Poll?.Then suggest your poll here.Complete ideas are more likely to be used.

      free欧美高清猪马牛俄罗斯Note that links may be used in choices but not in the title.

    Perl News
    Announcing Perl 7
    on Jun 24, 2020 at 15:14
    16 repliesby marto

      So in case you haven't been following the conference, Perl 7 has been announced.To quote brian_d_foy, a little free欧美高清猪马牛俄罗斯: 'Perl 7 is v5.32 with different settings. Your code should work if it? not a mess. Expect a user release within a year.', but you should probably just read the whole post, since, you know, details. Also Preparing for Perl 7.

      Update: s/chromatic/brian_d_foy/. Thanks 1nickt.

    Reminder: The Perl and Raku Conference in the Cloud - this week!
    on Jun 22, 2020 at 04:36
    2 repliesby haukex
    Supplications
    Reliably parsing an integer
    2 direct replies - Read more / Contribute
    by rdiez
    on Jun 29, 2020 at 10:04

      Hi all:

      I am writing the best Perl script since sliced bread:

      https://github.com/rdiez/Tools/tree/master/RDChecksum

      But I have other, equally super scripts around. Top of the pops.

      Anyway, I do not really trust my pesky users. Some of them have been known to pass some rubbish in command-line option --resume-from-line, instead of an integer. You know, something like --resume-from-line='from yesterday, you know what I mean'. The script is also reading a file which contains file sizes, and those sizes should be integers too. But who knows what the script might encounter there.

      So I decided to do some validation, like you do in C++ or in Java: read as string, convert it to integer, and if that fails, tell the user: "Invalid integer. Sod off."

      I was also hoping that, if the number is a real integer, Perl will run faster. In any case, I need to write those values to a file, so the output must look like a valid integer too.

      Alas, I am finding it difficult to do a simple integer validation in Perl. The first thing I did is to write routine has_non_digits() in order to discard anything that is obviously not an integer, see the script I mentioned above. But it looks like that is not enough. If you try the following test code:

      my $str = "99999999999999999999";print "What the string is: $str\n";my $strAsInteger = int( $str );print "Value of \$strAsInteger: $strAsInteger\n";printf "How printf sees it: %u\n", $strAsInteger;

      You will get this result:

      What the string is: 99999999999999999999Value of $strAsInteger: 1e+20How printf sees it: 18446744073709551615

      The results are puzzling. Note that there is no sign of a hint, a warning, or anything helpful there.

      Now, let's assume for a moment that anybody of us gives a damn about writing perfect Perl scripts. What would be the best way to parse an integer?

      Because my script is not doing any arithmetic, I would like to accept integers up to the maximum integer limit. This particular script is fussy and only wants to run on Perl versions compiled with 64-bit integer support, but I have other scripts that are not so choosy, so the integer size might be 32 bits. In any case, the maximum value is not a round base-10 value like "9999".

      In the name of all users that have the privilege of running my fine scripts, I thank you all.
           rdiez

    Async Net::AMQP::RabbitMQ
    3 direct replies - Read more / Contribute
    by dcpetrov
    on Jun 29, 2020 at 04:56
      Hey monks,I am little bit confused of all the RabbitMQ interfaces available for Perl. I'm currently using Net::RabbitFoot which has it last update back in 2011 and Net::RabbitFoot performance compared to Net::AMQP::RabbitMQ seems to be 4 times slower.So I am trying to migrate my code to Net::AMQP::RabbitMQ which uses librammitmq underneath.What I am currently struggling with, is how to run periodic task, since $mq->recv() is blocking. With Net::RabbitFoot I currently do something similar:
      my $ae = AnyEvent->timer ( after => 5, interval => 60, cb => \&logStats,);my $rf = Net::RabbitFoot->new()->load_xml_spec()->connect(host=> 'localhost',port=> 5672,user=> 'guest',pass=> 'guest',vhost => '/',timeout => 1,);...open channel and define on_consume handler... AnyEvent->condvar->recv;
      So I am wondering how can I achieve the same using Net::AMQP::RabbitMQ.Thanks.
    Simple Perl NMS Polling Engine
    3 direct replies - Read more / Contribute
    by mmoorreett
    on Jun 26, 2020 at 22:41

      Hi Monks

      I'm looking for some high level/framework advice on how to best develop a solution to build a *simple* network polling engine. I'm not looking to re-invent the wheel or want to implement a full blown NMS, just build something thats light weight and fast/efficient to plug a gap we have at the moment. Since being tasked with this, I have researched various frameworks I have not used before for multitasking/parallelism. E.g, threads, forks, event loop frameworks, such as POE, AnyEvent, IO:Async. I've used Perl periodically for various applications but not for something like this. I've started playing with the mentioned modules/frameworks and developed some samples, but I am unsure what is the best one. At a high level I need to:

      Periodically query an external data source for device data

      ICMP Ping poll on a configurable schedule (5 minute), potentially a couple of thousand devices, in parallel, return results for further processing

      Separate to ICMP poll, collect SNMP data on a configurable schedule (5 minute), potentially a couple of thousand devices, in parallel, return results for further processing

      Each poll thread/cycle needs a "TTL", that is, each poll thread must complete by X seconds, (not talking about an ICMP/SNMP timeout)

      Needs to run on Windows and Nix perl.

      Not sure what the best approach to take is. Having looked at a couple of open source NMS solutions i found built in perl, threads/forks were used, but these are over a decade old so I'm not sure if the event loop frameworks were considered or suitable.

      Looking to get some guidance on the most appropriate path to take so I don't need to re-invent the wheel, again :).

      Thanks in advance.

    Working with old code
    9 direct replies - Read more / Contribute
    by Anonymous Monk
    on Jun 26, 2020 at 12:31
      I have to work withold Perl code grown organically, written by others over the period of time, with 1000s of lines, andsometimewith single function over 100 lines. I often think, to convert it into organized fashion with small subroutines and clear logical flows, so that I can maintain it better going forward. I am afraid to compromise business logic.What solutions are recommended ? Thanks.
    incorrect methods yield success
    3 direct replies - Read more / Contribute
    by Anonymous Monk
    on Jun 26, 2020 at 05:27
      use strict;use warnings;my @json = jsonsolute('JSON::MaybeXS', 'encode', 'decode');print $json[0], "\n";print $json[1]->{key}, "\n";@json = jsonsolute();sub jsonsolute {my ($jsonpackage, $jsonefunction, $jsondfunction) = @_;$jsonpackage ||= 'JSON::MaybeXS';$jsonefunction ||= 'encode_json';$jsondfunction ||= 'decode_json';eval "require $jsonpackage";if ($@) {print "package $jsonpackage missing\n";} else {my $json = $jsonpackage->new(pretty => 1, canonical => 1);my $encoded = $json->$jsonefunction({key => 'value'});my $decoded = $json->$jsondfunction('{"key":"value"}');return $encoded, $decoded;}}results in :{ "key" : "value"}valueencountered object 'Cpanel::JSON::XS=SCALAR(0x564228375740)', but neit+her allow_blessed, convert_blessed nor allow_tags settings are enable+d (or TO_JSON/FREEZE method missing) at ...(my $encoded)
    Case insensitive string comparison
    2 direct replies - Read more / Contribute
    by DAN0207
    on Jun 26, 2020 at 02:32

      I have a text file with the content as follows

      SMS,SMS1,20190811,084500,servname,servid,servname1,s1,400,300,300,300,+300,300SMS,SMSh,20190811,084500,servname,servid,servname1,s1,700,300,300,300,+300,300SMS,SMSH,20190811,084500,servname,servid,servname1,s1,600,300,300,300,+300,300SMS,SMSi,20190811,084500,servname,servid,servname1,s1,800,300,300,300,+300,300SMS,SMSI,20190811,084500,servname,servid,servname1,s1,500,300,300,300,+300,300

      I have written the following line of code for case insensitive string comparison

      $$blk_ref = 'SMSblk' if $$blk_ref =~ /SMSi/i || $$blk_ref =~ /SMSI/i |+| $$blk_ref =~ /SMSh/i || $$blk_ref =~ /SMSH/i || $$blk_ref =~ /SMS1/+;

      But in the output file, i get the values only for SMSi,SMSh and SMS1.'The values of SMSI and SMSH are not taken.Kindly help to correct my code so that all the values are present in the output file

    If statement not working
    2 direct replies - Read more / Contribute
    by catfish1116
    on Jun 25, 2020 at 12:47

      I'm not getting any errors but program doesn't pick up the first character if it is a '@'. code below

      #* Progrmm prompts user fpr input and determines### which data type it is (scalar array or hash) ######################################################### print "Enter a string and I will determine the data type: "; chomp(my $_ = <STDIN>); if ($_ = (m/^[\$]\w/)) {print "\nThat is a scalar data type\n"; } elsif ($_ = (m/^[\@]\w/)) {print "\nThat is an array data type\n"; } else {print "\nData type not found\n"; }

      it will recognize the '$' leading character but not the '@'. In my code I have the match set up the same. TIAThe Catfish

    Best approach for temporarily swapping out a single perl module for a different version?
    7 direct replies - Read more / Contribute
    by nysus
    on Jun 25, 2020 at 10:32

      If I have a perl module installed on a development machine and I want to temporarily run a different version of that module (for example, a copy of the module in a local repo), I can modify the $PERL5LIB in my my bash profile and insert the path to the 'lib' directory in the temporary version of the module to the beginning of $PERL5LIB and then reload bash. Then, to restore the original module, I remove the path to the temporary module form $PERL5LIB and restart bash.

      This isn't too bad but just curious to know if others do the same thing or if there is some less hassle free way of doing this. Perhaps I should be using local::lib instead? Note that I'm using perlbrew so I'm not sure if local::lib is a viable option for me. Thanks.

      $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

    upload to PAUSE didn't seem to trigger tests
    2 direct replies - Read more / Contribute
    by scooter
    on Jun 25, 2020 at 03:39
      A few days ago, I uploaded Graphics::Fig v1.0.4 with a fix to a long outstanding bug.The upload seems to have worked.From another computer, I did an install Graphics::Fig from cpan and got the new version.But I didn't receive any emails after the upload with test results.Did the tests happen silently?Or were they not triggered?If the later, what can I do to trigger them?
    Push array to hash
    6 direct replies - Read more / Contribute
    by bartrad
    on Jun 24, 2020 at 10:32

      Hi, I've got a strange problem I can't get my head round. I'm pushing a hash and the first one appears in OK, but subsequent ones appear wrong?

      $VAR1 = \[{'desc' => 'xxx','ports' => [ { 'adminstate' => 'up', 'operationstate' => 'down', 'port' => '80', 'ismaster' => 'active' }, { 'adminstate' => 'up', 'operationstate' => 'down', 'port' => '81', 'ismaster' => 'active' }, { 'adminstate' => 'up', 'operationstate' => 'down', 'port' => '82', 'ismaster' => 'active' } ],'adminstate' => 'up','lagid' => '45','operationstate' => 'down'},${$VAR1}->[0],${$VAR1}->[0],${$VAR1}->[0],${$VAR1}->[0],

      The first structure appears just fine, but subsequent pushes only show as "${$VAR1}->[0]" - not sure why?

      foreach my $line ( split( /\n/, $c ) ) {if ( $line =~ m/someregex/ ) {if ( exists( $lag_detail{"ports"} ) ) {push( @{ $self->{"lags"} }, \%lag_detail );}%lag_detail = ( "lagid" => $lag, "lagdesc" => $4, "operationst+ate" => $3, "adminstate" => $2 );}}if ( $line =~ m/somemoreregex/ ) {my %port_detail = ( "port" => $1, "adminstate" => $2, "operationst+ate" => $4, "ismaster" => $3 );push @{ $lag_detail{"ports"} }, \%port_detail;}}
    Function Split, bug or error in the documentation?
    3 direct replies - Read more / Contribute
    by bojinlund
    on Jun 24, 2020 at 08:41

      use strict;use warnings;use 5.010;# from documentation:# ... and each of these:print join(':', split(//, 'abc', 3)), "\n";print join(':', split(//, 'abc', 4)), "\n";# produces the output a:b:c .say $^V;say $^O;__DATA__output:a:b:ca:b:c:v5.30.1

      In the second call there is an extra empty string. I am using Windows 10.

    Help with Geo::IP output
    7 direct replies - Read more / Contribute
    by Anonymous Monk
    on Jun 24, 2020 at 06:12

      Dear Monks,

      use Geo::IP;my $gi = Geo::IP->open("/somedirectory/dat/GeoIP.dat");my $record = $gi->record_by_addr('103.2.106.33');print $record->country_code,$record->country_code3,$record->country_name,$record->region,$record->region_name,$record->city,$record->postal_code,$record->latitude,$record->longitude,$record->time_zone,$record->area_code,$record->continent_code,$record->metro_code;

      The output I got from the above (based on the code at https://metacpan.org/pod/Geo::IP) is:

      -180.0000-180.00000--0

      I was expecting to see a country name in the print outputs...

      Am I missing something here?

      Also, the GeoIP.dat file is no longer available at Maxmind) so I'm using a previous version. How or where do I get the new dat format?

    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 cooling their heels in the Monastery: (9)
    As of 2020-06-29 17:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Do you really want to know if there is extraterrestrial life?



      Results (107 votes).Check out past polls.

      Notices?