Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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
Can't locate module added via APT
1 direct reply — Read more / Contribute
by mldvx4
on Oct 22, 2017 at 23:37

    I've tried adding a module with APT:

    # apt-get install libhtml-wikiconverter-markdown-perl

    and it seems to have put things in the right place

    # locate HTML | grep WikiConverter
    /usr/share/man/man3/HTML::WikiConverter::Markdown.3pm.gz
    /usr/share/perl5/HTML/WikiConverter
    /usr/share/perl5/HTML/WikiConverter/Markdown.pm
    /var/cache/man/cat3/HTML::WikiConverter::Markdown.3pm.gz

    Yet when I try the following:

    perl -e 'use HTML::WikiConverter;'

    I get this error:
    Can't locate HTML/WikiConverter.pm in @INC (you may need to install the HTML::WikiConverter module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at -e line 1.

    The manual says:

    SYNOPSIS use HTML::WikiConverter; my $wc = new HTML::WikiConverter( dialect => 'Markdown' ); print $wc->html2wiki( $html );
Installing Mail::Box
2 direct replies — Read more / Contribute
by gsd4me
on Oct 22, 2017 at 17:33

    Can anyone tell me please how to install Mail::Box (and its constituents) as I am failing miserably:

    I am using W10, PPM and when I do ppm install Mail::Box I get

    Can't find any package that provides Mail::Message for Mail::Box

    and

    Can't find any package that provides Mail::Reporter for Mail::Transport

    aren't these sort of things supposed to be recursive?
porting C code to Perl
2 direct replies — Read more / Contribute
by Discipulus
on Oct 22, 2017 at 15:27
    Hello nuns and monks,

    if you know me or not, I'm completely unaware of other programming languages; I just know a little Perl but I found myself in the rare situation where I need to translate a little code from C to Perl.

    Infact I rapidly (*) understood that is a task to be done by hand, and I've been told many times that these two languages share a lot in their syntax.

    My attempt is below and does not produces the output I expected (**).

    I looked a bit to some description of the C syntax to try to understand if there were some difference between the C operator and the correspective Perl's one. For example for ++ autoincrement or arithmentics ones. I found nothing relevant: many operators seems to act the same. Doubts remain about the C array syntax ( int A[len] ?? that I read as the elelment len of the array A is an int but..).

    Here below my attempt: can someone be so kind to point me where I lost in the translation? After a plain translation, when I possibly end with some working Perl code I'll arrange it into a more perlish version.

    use strict; use warnings; # #include <math.h> # #include <stdio.h> # #define N 100 my $n=100; # int len = floor(10 * N/3) + 1; my $len = 1 + int (10 * $n / 3); # int A[len]; my @a; $#a=$len-1; #? -1 ???? # for(int i = 0; i < len; ++i) {A[i] = 2;} for (my $i = 0; $i < $len; $i++){ $a[$i]= 2; } # int nines = 0; my $nines = 0; # int predigit = 0; my $predigit = 0; # for(int j = 1; j < N + 1; ++j) { for (my $j = 1; $j < $n + 1; ++$j){ # int q = 0; my $q = 0; # for(int i = len; i > 0; --i) { for(my $i = $len; $i > 0; $i--){ # int x = 10 * A[i-1] + q*i; my $x = 10 * $a[$i-1] + $q * $i; # A[i-1] = x % (2*i - 1); $a[$i-1] = $x % (2 * $i - 1); # q = x / (2*i - 1); } $q = $x / (2 * $i - 1); } # A[0] = q%10; $a[0]=$q%10; # q = q/10; $q=$q/10; # if (9 == q) { ++nines;} if (9 == $q){ ++$nines; } # else if (10 == q) { elsif(10 == $q){ # printf("%d", predigit + 1); printf("%d", $predigit + 1); # for (int k = 0; k < nines; ++k) { printf("%d", 0); } for (my $k = 0; $k < $nines; $k++){ printf("%d", 0);} # predigit, nines = 0; $predigit = $nines = 0; # } } # else { else{ # printf("%d", predigit); printf("%d", $predigit); # predigit = q; $predigit = $q; # if (0 != nines) { if(0 != $nines){ # for (int k = 0; k < nines; ++k) { for (my $k = 0; $k < $nines; $k++) { # printf("%d", 9); printf("%d", 9); # } } # nines = 0; $nines = 0; } } } # printf("%d", predigit); printf("%d", $predigit);

    (*) Not so rapid: I found a thread here at PM with a link to a C to perl translator, but I missed the <ironic> tags and my hands called rapidly gcc -P -E file.c > file.pl using the compiler I have shipped within strawberry perl. Was not useful and the next line gcc -Larry -Wall file.c > file.pl revealed me it was an humoristic faq or well a iaq..

    (**) Well i wanted to verify that the C code printed what I expected and I tried blindly using gcc to compile it (??) and using Inline::C but I had no success to not even install it on my strawberry perl.

    If you need my C source you can, obviously perl -lne 'print if s/\s?#\s//' my_post.pl

    Thanks

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
How do tell Perl to break only on undef?
1 direct reply — Read more / Contribute
by myuserid7
on Oct 22, 2017 at 05:18

    Hello, while working on a package I ran into a problem for which I could not find a pretty solution. I broke things down to come up with the example code below to demonstrate my issue. When this script is executed, it will print only "12568", because 0 is considered as false and this breaks the while loop. Now I could use while(1) and add some more lines to check $i for undef and then do a "last", but the package is supposed to be used by others so I want to keep it as simple as possible. What would be a pretty/easy way to make while only treat undef as a breaking argument?

    #!/usr/bin/perl -w use strict; use warnings; my $t = test->new(); while (my $i = $t->get) { print $i; }; package test; use strict; use warnings; my @list; sub new { my $self = shift; my $this = {}; @list = ( 1, 2, 5, 6, 8, 0, 9 ); bless($this, $self); return($this); }; sub get { return(shift(@list)); }; 1;
Printing out matches for two regular expressions
1 direct reply — Read more / Contribute
by Maire
on Oct 22, 2017 at 04:29

    Hi Monks,

    I am trying to get a very basic script to print out the matches from two regular expressions at once. Specifically, I am trying to print out all of the numbers (digits) and all of the words in between a "#" and the word "fin" in .txt files which take the following format:

    The 2 cats and the dog. The 8 cats and the 6 dogs. The 3 pigs and the 2 sheep. #story fin #cats and dogs fin #sheep fin

    So, for example, from the above file, I would expect the output to be:

    2 8 6 3 2 story cats and dogs sheep

Matching hash keys from different hashes and utilizing in new hash
4 direct replies — Read more / Contribute
by FIJI42
on Oct 21, 2017 at 16:22

    New to Perl and was wondering if anyone could provide suggestions, relevant examples or resources regarding a coding problem I'm having below. So I have two data files with tab-delineated columns, similar to the example below.

    File#1: GeneID ColA ColB Gene01 5 15 Gene02 4 8 Gene03 25 5 File#2: GeneID ColA ColC Gene01 12 3 Gene03 5 20 Gene05 22 40 Gene06 88 2

    The actual files I'm using have >50 columns and rows, but are similar to what's above. First, I want to input the files, establish variables holding the column names for each file, and establish hashes using the column 1 genes as keys and the concatenated values of the other 2 columns per key. This way there is one key per one value in each row of the hash. My trouble is the third hash %commongenes. I need to find the keys that are the same in both hashes and use just those keys, and their associated values in both files, in the third hash. In the above example, this would be the following key value pairs:

    File1: File2: Gene01 5 15 Gene01 12 3 Gene03 25 5 Gene03 5 20

    I know the following if loop is incorrect, yet concatenation of columns from both files (similar to below) is similar in form to what I'd like to have.

    if ($tmpArray1[0] eq $tmpArray2[0]){ $commongenes{$tmpArray2[0]} = $tmpArray1[1].':'.$tmpArray1[2].':'.$tmpArray2[1].':'.$tmpArray2[2 +]; }

    Here is the main body of the code below:

    #!/usr/bin/perl -w use strict; my $file1=$ARGV[0]; my $file2=$ARGV[1]; open (FILE1, "<$file1") or die "Cannot open $file1 for processing!\n" +; open (FILE2, "<$file2") or die "Cannot opent $file2 for processing!\n +"; my @fileLine1=<FILE1>; my @fileLine2=<FILE2>; my %file1_allgenes=(); my %file2_allgenes=(); my %commongenes =(); my ($file1_group0name, $file1_group1name, $file1_group2name)=('','',' +',''); my ($file2_group0name, $file2_group1name, $file2_group2name)=('','',' +',''); for (my $i=0; $i<=$#fileLine1 && $i<=$#fileLine2; $i++) { chomp($fileLine1[$i]); chomp($fileLine2[$i]); my @tmpArray1=split('\t',$fileLine1[$i]); my @tmpArray2=split('\t',$fileLine2[$i]); if ($i==0) { ## Column Names and/or Letters $file1_group0name=substr($tmpArray1[0],0,6); $file1_group1name=substr($tmpArray1[1],0,4); $file1_group2name=substr($tmpArray1[2],0,4); $file2_group0name=substr($tmpArray2[0],0,6); $file2_group1name=substr($tmpArray2[1],0,4); $file2_group2name=substr($tmpArray2[2],0,4); } if ($i!=0) { ## Concatenated values in 3 separate hashes + if (! defined $file1_allgenes{$tmpArray1[0]}) { $file1_allgenes{$tmpArray1[0]}=$tmpArray1[1].':'.$tmpArray1[2] +; } if (! defined $file2_allgenes{$tmpArray2[0]}) { $file2_allgenes{$tmpArray2[0]}=$tmpArray2[1].':'.$tmpArray2[2] +; } if ($tmpArray1[0] eq $tmpArray2[0]){ $commongenes{$tmpArray2[0]} = $tmpArray1[1].':'.$tmpArray1[2].':'.$tmpArray2[1].':'.$tmpArray2[2 +]; } } my @commongenes = %commongenes; print "@commongenes\n\n"; }
Accessing values outside subroutine
1 direct reply — Read more / Contribute
by Anonymous Monk
on Oct 21, 2017 at 04:08

    I am trying to access the values which is defined inside a subroutine . Here is the code flow

    Sub a { my @array = (1, 2, 3); } Sub b { foreach $value (@array) }

    I tried to define array as "our " keyword in Sub a. But, it is not retaining the values when it is accessesed inside Sub b . Is there a way to make it work

Advice: Async Options for fire-and-forget subroutine
4 direct replies — Read more / Contribute
by mwb613
on Oct 20, 2017 at 14:51

    Thanks in advance for looking.

    I took a look back through earlier questions and saw some helpful results but some of them were older and some didn't quite match my use case. I am writing a Perl module for a piece of software called OpenSIPs (a SIP server), the module itself does some message de-construction and re-construction that's not easy to do in the OpenSIPs config file itself. I have also been extended it to logging certain messages and statistics and right now my solution for that is Redis PUB/SUB. This is working fine but it is adding some latency that is not really necessary considering it is a non-essential function of the SIP transaction.

    What I would like to do is, rather than wait for the Redis transaction to complete (sometimes in the range of 20-30 ms depending on where the Redis server is), just run the Redis PUB/SUB command asynchronously and not worry about the reply or even wait to get the acknowledgment in my main script. I've seen a few modules mentioned in earlier conversations here: threads, AnyEvent, Async, etc and also some non modular solutions like backticks, etc. What I'm looking for is the simplest, most lightweight way to call a Perl subroutine (passing it some info -- a JSON encoded string) and not worry about the response or whether it is successful. I'd appreciate any advice anyone is willing to give.

    Thanks!

Exception handling
2 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 20, 2017 at 03:33

    my script logs in to console of router and clear all the user (console) lines. When it encounters the current line, it comes out of the script. Is there a way to handle this situation, more precisely, when it encounters current line, it should not clear and it should go to the next line which is used by somebody else

    ######################### sub clear_line { ######################### print "router name? "; my $r = <STDIN>; chomp($r); print "term? "; my $terms = <STDIN>; chomp($terms); my $values; my @test_array; my @data_set = ( JT->new( host => $r ), ); foreach my $rh (@data_set) { for (my $term = $terms; $term <=40; $term++) { $rh->cmd("request system logout terminal pts/$term"); } } }

    Logs below

    [shell]$ ./ft_generic_bk.pl router name? abc term? 1 Oct 20 00:21:07 [INFO ] [abc] JT::Device::connect: abc is connected vi +a /volume/labtools/bin/nicetelnet pid 16210 Oct 20 00:21:09 [INFO ] [abc] [cmd] cat /usr/share/cevo/cevo_version Oct 20 00:21:10 [INFO ] [abc] [cmd] request system logout terminal pts +/1 Oct 20 00:21:12 [INFO ] [abc] [cmd] request system logout terminal pts +/2 Oct 20 00:21:14 [INFO ] [abc] [cmd] request system logout terminal pts +/3 Oct 20 00:21:16 [INFO ] [abc] [cmd] request system logout terminal pts +/4 Oct 20 00:21:17 [INFO ] [abc] [cmd] request system logout terminal pts +/5 Oct 20 00:21:17 [INFO ] [abc] [cmd] request system logout terminal pts +/6 Oct 20 00:21:18 [INFO ] [abc] [cmd] request system logout terminal pts +/7 Oct 20 00:21:18 [INFO ] [abc] [cmd] request system logout terminal pts +/8 Oct 20 00:21:19 [INFO ] [abc] [cmd] request system logout terminal pts +/9 Oct 20 00:21:20 [INFO ] [abc] [cmd] request system logout terminal pts +/10 Oct 20 00:21:21 [INFO ] [abc] [cmd] request system logout terminal pts +/11 Oct 20 00:21:22 [INFO ] [abc] [cmd] request system logout terminal pts +/12 Oct 20 00:21:23 [INFO ] [abc] [cmd] request system logout terminal pts +/13 Oct 20 00:21:24 [INFO ] [abc] [cmd] request system logout terminal pts +/14 Oct 20 00:21:25 [INFO ] [abc] [cmd] request system logout terminal pts +/15 Oct 20 00:21:26 [INFO ] [abc] [cmd] request system logout terminal pts +/16 Oct 20 00:21:27 [INFO ] [abc] [cmd] request system logout terminal pts +/17 Oct 20 00:21:28 [INFO ] [abc] [cmd] request system logout terminal pts +/18 Oct 20 00:21:29 [WARN ] [abc] Device response :Connection closed by fo +reign host. Oct 20 00:21:29 JT.pm:2877 [ERROR] [abc] JT::Device::_send: Expect rep +orted 3:Child PID 16210 exited with status 256 JT::error_handler HARD at /volume/labtools/lib/JT/Device.pm li +ne 2867, <STDIN> line 2. JT::Device::_send('JT::JUNOS=HASH(0xf0867c4)', 'cmd', 'request + system logout terminal pts/18', 'timeout', 60, 'timeout_ok', 0, 'slo +w', 0, ...) called at /volume/labtools/lib/JT/JUNOS.pm line 2106 JT::JUNOS::cmd('CMD', 'request system logout terminal pts/18') + called at ./ft_generic_bk.pl line 1912 ft_generic_tc::clear_line() called at ./ft_generic_bk.pl line +2417 JT: die ./ft_generic_bk.pl with exit code 18 CONNECT_LOST

    Line 18 is used by my script and it disconnects and i should avoid it. Is there a way to avoid my line and go to the next line ?

Using negative lookahead
5 direct replies — Read more / Contribute
by ibm1620
on Oct 18, 2017 at 21:14
    I want to create a regex that will identify a string surrounded by quotes, and remove the quotes. If the quote symbol appears within the string, the match should fail. The quotes can be either ' or ". Eventually they might be multi-character strings (e.g. ''). I'm not concerned at this point about recognizing escaped embedded quotes. This is slightly contrived .. I mostly want to understand why a negative lookahead isn't working the way I thought it would.

    I sure would appreciate being shown what I'm misunderstanding.

    #!/usr/bin/env perl use warnings; use strict; my @cases = ( q{'abc"def'}, q{'abc'}, q{"abc"}, q{''}, q{'abc'def'}, # Want this to fail matching q{'This shouldn't match'}, # Want this to fail matching q{"This isn't a problem"}, q{"abc}, q{abc"}, q{abc}, q{'abc"}, q{'ab''}, # Want this to fail matching ); strip_quotes($_) for @cases; # If we can remove a matching pair of single or double quotes from # a string, without the quote symbol also appearing within the string, # do so. Otherwise don't change the string. sub strip_quotes { my $line = shift; print "\n$line\n"; # NO NEGATIVE LOOKAHEAD # This works except it allows an embedded delimiter if ( $line =~ m{^ # anchor ( # capture delimiter in pos 1 ["'] # delim is single or double quote ) (.*) # anything \g1$}x # finally, the delim ) { print " 1- Got a match: delimiter was {$1}, body was {$2}\n"; } else { print " 1- No match.\n"; } # ATTEMPTING NEGATIVE LOOKAHEAD # This should fail if the delimiter is found in non-terminal pos. if ( $line =~ m{^ # anchor ( # capture delimiter in pos 1 ["'] # delim is single or double quote ) (.*(?!\g1)) # neg lookahead for delim \g1$}x # finally, the delim ) { print " 2- Got a match: delimiter was {$1}, body was {$2}\n"; } else { print " 2- No match.\n"; } }
    Result:
    'abc"def' 1- Got a match: delimiter was {'}, body was {abc"def} 2- No match. 'abc' 1- Got a match: delimiter was {'}, body was {abc} 2- No match. "abc" 1- Got a match: delimiter was {"}, body was {abc} 2- No match. '' 1- Got a match: delimiter was {'}, body was {} 2- No match. 'abc'def' 1- Got a match: delimiter was {'}, body was {abc'def} 2- No match. 'This shouldn't match' 1- Got a match: delimiter was {'}, body was {This shouldn't match} 2- No match. "This isn't a problem" 1- Got a match: delimiter was {"}, body was {This isn't a problem} 2- No match. "abc 1- No match. 2- No match. abc" 1- No match. 2- No match. abc 1- No match. 2- No match. 'abc" 1- No match. 2- No match. 'ab'' 1- Got a match: delimiter was {'}, body was {ab'} 2- No match.
Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?"
1 direct reply — Read more / Contribute
by kikuchiyo
on Oct 18, 2017 at 13:49

    Consider the following script:

    #!/usr/bin/perl use strict; use warnings; use Test::More; use Data::Dumper; my $hash = { '50' => [ 1 ] }; print Dumper $hash; is(keys %{$hash}, 1, q/keys %{$hash} is 1/); is(scalar @{$hash->{'50'}}, 1, q/$hash->{'50'} is 1/); is(scalar @{$hash->{'100'}}, 0, q/$hash->{'100'} is 0/); print Dumper $hash; done_testing();

    With Perl 5.24.3 it runs to the end and all tests pass, even though I would expect that it dies with an "Can't use an undefined value as an ARRAY reference" error when it tries to dereference $hash->{'100'} which indeed does not exist.

    Compare with

    #!/usr/bin/perl use strict; use warnings; my $hash = { '50' => [ 1 ] }; print scalar @{$hash->{'100'}};

    which dies with the expected error.

    Under Perl 5.16 the first program also dies with the expected error. (This is how we initially noticed the problem: a program that was developed on 5.22+ needed to be ported to Centos 7 which has 5.16, and the tests began to fail there.)

    What is going on here?

    (Errata: Now I've ran with more Perl versions (perversions), and it doesn't die under perl 5.22 and above, but dies as expected under perl 5.20 and below)

Puzzle Regex: Letter Frequency Arithmetic Sequence
6 direct replies — Read more / Contribute
by QM
on Oct 17, 2017 at 11:03
    I ran across a blog post about an interesting word characteristic, and wondered if a regex can be written to match this (e.g., with the plan to search a dictionary file). I suspect the answer is no, without invoking the magic "code in a regex".

    Unfortunately, I don't have time now to try my hand at it, but I thought I'd post it here for everyone to have a go.

    Update: Possible puzzles:

    1) Find the longest words where each letter used has a different frequency.
    2) Find the longest words where letter frequencies are sequential (e.g., 3,4,5,6).
    3) Find the longest words where letter frequencies are sequential starting from 1.

    Use any dictionary you like. If you have a mahvelous dictionary, drop a link here.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

New Meditations
[Perl 6]: Small discoveries V, True / False / FileNotFound
1 direct reply — Read more / Contribute
by holli
on Oct 19, 2017 at 13:54
    Omg, I love this. Did you ever have a clear, slick little function that needs to return a boolean, and you also want to communicate an error condition? You basically have the choice of returning two values, reversing the consuming condition (meaning an empty return value be considered true), or using a string reference as an argument to the function.

    Witness Perl 6:
    sub slick() { if do-stuff { return "SomeValue"; } else { return "Some error message" but False; } } if my $result = slick { process( $result ); } else { log-error( $result ); }


    holli

    You can lead your users to water, but alas, you cannot drown them.
Be prepared for CSV injections in spreadsheet
3 direct replies — Read more / Contribute
by Tux
on Oct 18, 2017 at 07:34

    Read this article to get an idea of how dangerous it can be to blindly accept macro's in spreadsheets. Be it MS Excel or Google spreadsheets, they all suffer.

    You cannot blame CSV for it. CSV is just passive data.

    Once you load or open a CSV file into something dangerous as a spreadsheet program that allows formula's to be execcuted on open, all bets are off. Or are they?

    The upcoming Text::CSV_XS has added a new feature to optional take actions when a field contains a leading =, which to most spreadsheet programs indicates a formula.

    On both parsing and generating CSV, you will be able to specify what you want to do (where "formula" does not go beyond the fact that the field starts with a =):

    • Do nothing special (default behavior) and leave the text as-is
    • Die whenever a formula is seen
    • Croak when a formula is seen
    • Give a warning where a formula is seen
    • Replace all formulas with an empty string
    • Remove all formulas (replace with undef

    Code speaks loader than words ...

    I'm pretty pleased with the diagnostics

    $ cat formula.csv a,b,c 1,=2+3,4 6,,7,=8+9, $ perl -MCSV -e'$_ = dcsv (in => "formula.csv", bom => 1, formula => " +diag")' Field 2 (column: 'b') in record 1 contains formula '=2+3' Field 4 in record 2 contains formula '=8+9'

    Expect this to be available by next week.


    Enjoy, Have FUN! H.Merijn
Perl6 discoveries ó floating-point
2 direct replies — Read more / Contribute
by Grimy
on Oct 18, 2017 at 06:59
    Anonymous Monk brought up a really interesting discovery here. Unfortunately, that thread got derailed, so Iím making a separate one, as suggested by Your Mother. One of the first things I found while testing is this really interesting tidbit:
    $ perl6 -e 'say 0.99999999999999999000001' 1.000000000000000073886090 $ perl6 -e 'say 0.99999999999999999000001 > 1' True
    But then I realized I was using an outdated Rakudo (2017.04). So I updated to 2017.09, and now those print 1 and False, respectively. Thereís still some interesting behavior in 2017.09, though:
    $ perl6 -e 'say 0.7777777777777777777770' 0.77777777777777785672697 $ perl6 -e 'say 0.7777777777777777777771' 0.777777777777777767909129
    Note that the second number printed is strictly smaller than the first one, even though the second source number is strictly larger than the first one, spelled in the same fashion and to the same number of significant digits! However, comparison and subtraction still return exact results:
    $ perl6 -e 'say 0.7777777777777777777771 > 0.7777777777777777777770' True $ perl6 -e 'say 0.7777777777777777777771 - 0.7777777777777777777770' 1e-22
    Okay, thatís probably because one is a Num and the other is a Rat, so letís convert everything to Num explicitly:
    $ perl6 -e 'say Num(0.7777777777777777777770)' + 0.777777777777778 $ perl6 -e 'say Num(0.7777777777777777777771)' 0.777777777777778 $ perl6 -e 'say Num(0.7777777777777777777770) > Num(0.7777777777777777 +777771)' True $ perl6 -e 'say Num(0.7777777777777777777770) - Num(0.7777777777777777 +777771)' 1.11022302462516e-16
    Huh. Now they print the same, but theyíre still different numbers when compared. Note that the sign of the difference got switched:
    $ perl6 -e 'my $a = 0.7777777777777777777770; my $b = 0.77777777777777 +77777771; say $a <=> $b; say Num($a) <=> Num($b)' + Less More
    Also interesting is that many Nums donít survive a round-trip to Str:
    $ perl6 -e 'my $a = Num(1/9); say $a == Num(Str($a))' False
    Can anyone point me to the Perl6 specs/docs/whatever that explain those behaviors?
New Cool Uses for Perl
Determining Gaps and Overlap in Timestamped Data
No replies — Read more | Post response
by haukex
on Oct 20, 2017 at 11:16

    I've recently been working with large sets of timestamped measurement data from different devices, often recorded at different times on different days and spread across multiple files. Since I'm not always involved in the recording of the data, I need to look at when the devices were turned on and off, any gaps in the data, etc., in particular for which spans of time all devices were measuring at the same time, since that's the data that then needs to be analyzed. The timestamps are jittery, and data doesn't always come in order (or, equivalently, I'd like to not have to sort everything by timestamp). Set::IntSpan's union and intersect operations make this pretty easy!

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-10-23 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (279 votes). Check out past polls.

    Notices?