Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Don Coyote's scratchpad

by Don Coyote (Hermit)
on Jul 01, 2010 at 17:29 UTC ( [id://847567]=scratchpad: print w/replies, xml ) Need Help??


home node

Note: You cannot optimize code you have not yet written!

Moving from scripting to programming handy thread for directions

Sequence Lemma: A precursive sequence to the general pythagorean quadrance generation sequence.

Usually the reduced Pythagorean Triples are the subject of the sequence. And it is such that this is essentially the square1 of a precursive sequence to the general pythagorean triples generator.

Why not just work with the reduced triples?
The pythagorean relation is in the quadratic. Further, that relation itself is a special case. The reduced triples are Corollories, after the fact, Lemmas prior.2

Do sequences require proofs like Theorems do?
Not sure

Are you pretending a sequence is a Theorem?
That is probably what I am doing here, yes.

[ n, nat 2>=n; ip, [ i, int[ m, nat 0>=m ] ] ; pOseq, {ip1,ip2,ip3} : pOseq(n) => L(Q), [ Q1, Q3, Q2 ] ] v0.01
What this is attempting to state:
Where, n is a natural number equal or greater than two.
ip an ordered pair of multiset of integers, indexed by l a nat equal or greater than 0, representing the power to which the nat n is exponentiated in that position.
pOseq(ip3) is an Oset(Ordered_Set) consisting of three sequences of three Integral_Polynumbers.
A List L of three quadrances q, L(Q), satisfying the Pythagorean identity can be generated, by evaluating each of the ip in the oset P by the natural number n.

this is going to take some time.

# [ pOnseq(2) > = 9, 25, 16 #{ _ _ , _ _ , _ _ } @2 = [ , , ] # 1\ 1\ 0\ # 4 4 0 # 4 8 4 # 8 8 # 4 4 #
1. Assuming the sequence can be squared. Currently I understand that it is allowable/doable.
2. ... ?
9.

end home node



started out trying to simply answer a question, but got bogged down by lots of different issues.

intention was to throw some values into Devel::Peek and then regex process them to get at what they were.

after spending most of the day on this, I still have no response for the OP and some dubiously serious code for posting as a response.

is it just me?

#!perl use strict; use warnings; use feature qw/state say/; use Devel::Peek; my @array = ( "0", "0\n", 0, '0', '0'."\n" ); foreach my $zeroe( @array ){ state $za; say "\$zeroe $zeroe\__________"; # @$za = Dump $zeroe; state $fh_err; local *MYSTDERR = *STDERR; open STDERR, '>', 'tmp.err' or die $!; # dies to Term Dump $zeroe; Dump defined $zeroe; Dump length $zeroe; Dump 0+$zeroe; close STDERR; *STDERR = *MYSTDERR; what_is_it(); say "[][][][][][][][][][]\n"; } unlink 'tmp.err'; sub what_is_it{ # my $output = shift; # while(defined( my $next = shift @$output )){ # state $c; # print ++$c,": $next"; state $fh_err; open $fh_err, '<', 'tmp.err' or die $!; # .... while( defined ( my $nextline = <$fh_err> ) ){ # state $c; # print $c+=1," $nextline"; print $nextline; }; close $fh_err; unlink{ 'tmp.err' }; }

output

$zeroe 0__________ SV = PV(0xeb850c) at 0xeba53c REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x26c4bec "0"\0 CUR = 1 LEN = 12 SV = PVNV(0xeb945c) at 0xeb72c0 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0xeb2d74 "1"\0 CUR = 1 LEN = 12 SV = IV(0x26c37f8) at 0x26c37fc REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 1 SV = IV(0x26c37e8) at 0x26c37ec REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 0 [][][][][][][][][][] $zeroe 0 __________ SV = PV(0xeb851c) at 0xeba5cc REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x26c4ccc "0\n"\0 CUR = 2 LEN = 12 SV = PVNV(0xeb945c) at 0xeb72c0 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0xeb2d74 "1"\0 CUR = 1 LEN = 12 SV = IV(0x26c37f8) at 0x26c37fc REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 2 SV = IV(0x26c37e8) at 0x26c37ec REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 0 [][][][][][][][][][] $zeroe 0__________ SV = PVIV(0x2663380) at 0xeba61c REFCNT = 2 FLAGS = (IOK,POK,pIOK,pPOK) IV = 0 PV = 0x26c4e4c "0"\0 CUR = 1 LEN = 12 SV = PVNV(0xeb945c) at 0xeb72c0 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0xeb2d74 "1"\0 CUR = 1 LEN = 12 SV = IV(0x26c37f8) at 0x26c37fc REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 1 SV = IV(0x26c37e8) at 0x26c37ec REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 0 [][][][][][][][][][] $zeroe 0__________ SV = PV(0xeb8534) at 0xeba64c REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x26c4d8c "0"\0 CUR = 1 LEN = 12 SV = PVNV(0xeb945c) at 0xeb72c0 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0xeb2d74 "1"\0 CUR = 1 LEN = 12 SV = IV(0x26c37f8) at 0x26c37fc REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 1 SV = IV(0x26c37e8) at 0x26c37ec REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 0 [][][][][][][][][][] $zeroe 0 __________ SV = PV(0xeb854c) at 0xeba66c REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x26c4e2c "0\n"\0 CUR = 2 LEN = 12 SV = PVNV(0xeb945c) at 0xeb72c0 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0xeb2d74 "1"\0 CUR = 1 LEN = 12 SV = IV(0x26c37f8) at 0x26c37fc REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 2 SV = IV(0x26c37e8) at 0x26c37ec REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 0 [][][][][][][][][][] Press any key to continue . . .

re check possible combination of sum using given array check possible combinations of sum using given array

This looks like a problem that could be dealt with using prime factorisation. But, to get a prime factorisation you need to check the possible combinations of a sum.

tentatively, problem restated: Given a number A, and a List B consisting of one or more numbers, which numbers from B:

  • are divisors of A
  • can be summed to any divisor of A
  • are divisors of any other number in B
  • can be summed to any divisor of any other number from B
  • are divisors of A
  • can be summed to any divisor of A
  • are divisors of any other number in B that is a divisor of A
  • can be summed with any other number in B to A or any B That is a Divisor of A.

When all numbers in B satisfy (some or all?) of these conditions, supply the multiplicities of the numbers required for firstly the summations up to the divisors of both A and B, and secondly any reaminders of numbers that are not divisors but are used in the summation composition.

note: restatement subject to re-interpretation using more appropriate terminology where required. That is, I may mean factor where I have stated divisor. I may mean composite summation. Also to be clarified - where remainders that are not divisors are used in the summation.

Before moving on to a List of multiple numbers, understanding how the failing case works is probably key. With A being 3 and a B being a 1 List from 2.

  • A: Num 3
  • B: List(2,1)
where B contains only 1 item, B could be construed as a List or a Set. Right now, I am (attempting to be) keeping it simple as an argument list.

Plan of action, is to match A with B. A is a number, B is a List. done. Ok, Let us use b to mean the number in the List.

Plan of action, is to match A with b. Failure is a result of either

  • b not being a divisor of A
  • any multiple of b not being a divisor of A
This case also highlights another aspect in that b itself is smaller than A, and its first multiple (2b) is larger than A. These conditions in relation to each other should form the basis of an appropriate algorithm for the problem if not solve it.

No errrors found.

getting there, I can now 'split' rather, substitute and count the substitutions, so to say, and test for a remainder, which is half the problem.

output as it stands

|| ||| ||||| ||||||| ||||||||||||||| |||||||||||||||||||||| +||||||||||||||||||||| testing prim nat: || split_pat: (?^u:(\|\|)) splitted: 1 x || h remainder: prim nat was || prim nat now testing prim nat: ||| split_pat: (?^u:(\|\|)) splitted: 1 x || h remainder: | prim nat was ||| prim nat now | testing prim nat: ||||| split_pat: (?^u:(\|\|)) splitted: 2 x || h remainder: | prim nat was ||||| prim nat now | testing prim nat: ||||||| split_pat: (?^u:(\|\|)) splitted: 3 x || h remainder: | prim nat was ||||||| prim nat now | testing prim nat: ||||||||||||||| split_pat: (?^u:(\|\|)) splitted: 7 x || h remainder: | prim nat was ||||||||||||||| prim nat now | testing prim nat: ||||||||||||||||||||||||||||||||||||||||||| split_pat: (?^u:(\|\|)) splitted: 21 x || h remainder: | prim nat was ||||||||||||||||||||||||||||||||||||||||||| prim nat now | || 2 my todo hex() 1 x || remainder: ||| 3 my todo hex() 1 x || remainder: | ||||| 5 my todo hex() 2 x || remainder: | ||||||| 7 my todo hex() 3 x || remainder: | ||||||||||||||| f my todo hex() 7 x || remainder: | ||||||||||||||||||||||||||||||||||||||||||| 2b my todo hex() + 21 x || remainder: | Press any key to continue . . .

intended New Meditation 07/07/19

WT: problems installing standalone Perl Data Language (PDL) - debugging and hopefully resolution
perl -d -MExtUtil::Command::MM ... test harness() .\t\*.t

  • Recently started using Padre with Strawberry Perl (implies Win32)
  • There is a padre distribution that provides PDL(Perl Data Language) that I have not installed
  • for giggles I ran cpanm -i PDLclarify and it failed the tests

Padre supplies strawberry perl version 5.14 ish. My initial thought is that I am dealing with version discrepancies. Turns out to be tmp dir permissions denied.

Already having made off the cuff remarks about code in another of the Authors’2nd guess! heheh modules during a response to a SoPW, that may have appeared obsequious, I was determined to ensure I investigated the failure completely before once again invoking the wrath of the gods...

the Module::Compile log. thus far

cpanm (App::cpanminus) 1.7044 on perl 5.014002 built for MSWin32-x86-m +ulti-thread Work directory is C:\Users\ZOMBIKE~1/.cpanm/work/1562478735.5744 You have make C:\Dwimperl\c\bin\dmake.exe You have LWP 6.03 Falling back to Archive::Tar 1.80 Searching Module::Compile () on cpanmetadb ... --> Working on Module::Compile Fetching http://www.cpan.org/authors/id/I/IN/INGY/Module-Compile-0.37. +tar.gz -> OK Unpacking Module-Compile-0.37.tar.gz Entering Module-Compile-0.37 Checking configure dependencies from META.json Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.36) Configuring Module-Compile-0.37 Running Makefile.PL Checking if your kit is complete... Looks good Generating a dmake-style Makefile Writing Makefile for Module::Compile Writing MYMETA.yml and MYMETA.json -> OK Checking dependencies from MYMETA.json ... Checking if you have Capture::Tiny 0 ... Yes (0.15) Checking if you have Digest::SHA1 2.13 ... Yes (2.13) Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.36) Checking if you have App::Prove 0 ... Yes (3.23) Building and testing Module-Compile-0.37 cp lib/Module/Optimize.pod blib\lib\Module\Optimize.pod cp lib/Module/Compile/Opt.pm blib\lib\Module\Compile\Opt.pm cp lib/Module/Compile.pm blib\lib\Module\Compile.pm cp lib/Module/Optimize.pm blib\lib\Module\Optimize.pm cp lib/Module/Compile/Opt.pod blib\lib\Module\Compile\Opt.pod cp lib/Module/Compile.pod blib\lib\Module\Compile.pod C:\"Dwimperl\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Har +ness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib +', 'blib\arch')" t/*.t t/author-pod-syntax.t .. skipped: these tests are for testing by the a +uthor t/compile.t ............ ok # Failed test '.pmc load works same' # at t/data1.t line 29. # got: '1' # expected: '0' # Output was: t/data2.t.subrun .. # No subtests run # # Test Summary Report # ------------------- # t/data2.t.subrun (Wstat: 0 Tests: 0 Failed: 0) # Parse errors: No plan found in TAP output # Files=1, Tests=0, 1 wallclock secs ( 0.06 usr + 0.05 sys = 0.11 C +PU) # Result: FAIL # Error was: # Looks like you failed 1 test of 4. t/data1.t .............. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/4 subtests t/fold_blocks.t ........ ok t/lexical.t ............ ok t/orz.t ................ ok t/parse.t .............. ok t/pm.t ................. skipped: In progress... t/pmc.t ................ ok Test Summary Report ------------------- t/data1.t (Wstat: 256 Tests: 4 Failed: 1) Failed test: 4 Non-zero exit status: 1 Files=9, Tests=23, 2 wallclock secs ( 0.06 usr + 0.05 sys = 0.11 CP +U) Result: FAIL Failed 1/9 test programs. 1/23 subtests failed. dmake.exe: Error code 255, while making 'test_dynamic' -> FAIL You don't seem to have a PAGER :/ Entering C:/Users/ZOMBIKE~1/.cpanm/work/1562478735.5744/Module-Compile +-0.37 with C:\WINDOWS\system32\cmd.exe

stepped through using variety of  c line and  c sub commands in db. I can now get to the incident reasonably quickly. But still not as efficient as I would like to be at this point. A bit of time and usage will help with that. I do not want to dump tons of readout wihtout it being somwhat useful to the reader. So intend to write up post resolution. pencil in a date in my devnulliary.

It is some kind of $ENV{TMP} that IO::Handle::open is returning a fail on test.

DB<2> s Capture::Tiny::capture((eval 40)[C:/Dwimperl/perl/site/lib/Capture/Tin +y.pm:38]:1): 1: sub capture(&;@) {unshift @_, 1, 1, 0, 0; goto \&_capture_tee; +} + DB<2> ... File::Spec::Win32::tmpdir(C:/Dwimperl/perl/lib/File/Spec/Win32.pm:73): File::Temp::tempfile(C:/Dwimperl/perl/lib/File/Temp.pm:1381): 1381: croak "Error in tempfile() using $template: $errstr" 1382: unless (($fh, $path) = _gettemp($template, 1383: "open" => $options{'OPEN'} +, 1384: "mkdir"=> 0 , 1385: "unlink_on_close" => $unli +nk_on_close, 1386: "suffixlen" => length($opt +ions{'SUFFIX'}), 1387: "ErrStr" => \$errstr, 1388: "use_exlock" => $options{E +XLOCK}, 1389: ) ); DB<15> s File::Temp::_gettemp(C:/Dwimperl/perl/lib/File/Temp.pm:360): 360: if (scalar(@_) % 2 != 0) { ... DB<15> File::Temp::_replace_XX(C:/Dwimperl/perl/lib/File/Temp.pm:627): 627: my $end = ( $] >= 5.006 ? "\\z" : "\\Z" ); + DB<15> s File::Temp::_replace_XX(C:/Dwimperl/perl/lib/File/Temp.pm:629): 629: if ($ignore) { + DB<15> x $end 0 '\\z' + DB<16> ... File::Temp::_replace_XX(C:/Dwimperl/perl/lib/File/Temp.pm:632): 632: $path =~ s/X(?=X*$end)/$CHARS[ int( rand( @CHARS ) ) ]/ge; + DB<16> x $path 0 '\\XXXXXXXXXX' ... DB<18> File::Temp::_replace_XX(C:/Dwimperl/perl/lib/File/Temp.pm:634): 634: return $path; + DB<18> x $path 0 '\\ApibgN64sj' ... DB<20> s File::Spec::Win32::splitpath(C:/Dwimperl/perl/lib/File/Spec/Win32.pm:2 +10): 210: my ($volume,$directory,$file) = ('','',''); + DB<20> x @_ 0 'File::Spec' 1 '\\ApibgN64sj' ... DB<29> File::Temp::_gettemp(C:/Dwimperl/perl/lib/File/Temp.pm:513): 513: $open_success = sysopen($fh, $path, $flags, 0600); + DB<29> x $fh,$pat +h,$flags 0 undef 1 '\\ApibgN64sj' 2 34178 + DB<30> s File::Temp::_gettemp(C:/Dwimperl/perl/lib/File/Temp.pm:515): 515: if ( $open_success ) { + DB<30> x $open_su +ccess 0 undef + DB<31>

The main learning here is make a personal log as you go, for ease of dissemination at later date.

Currently thinking of supplying a tmp dir to the program on the local machine. Although this would likely fail on any updates as any systemised install process will just use downloaded code. And at this point the issue does not appear to be perl related. Basically a workaround, until I can identify a more robust solution.


re ABN Checker
#!/usr/bin/perl use v5.20; use strict; use warnings; my $Num = Prepare_Num( q'51 824 753 556' ); my $verified = check_calc($Num); if( $verified == 1){ say "Valid ABN" }else{ say "ABN check has been unsuccessful" } sub check_calc{ my $Numset = shift; my $woset = weighting_oset(); --$Numset->[0][0]; print_oset($Numset); my $sum; for my $index( 0 .. 10 ){ $sum += $Numset->[$index][0] *= $woset->[$index][0]; } print_oset($Numset); $sum %89 == 0; } sub Prepare_Num{ my $NumString = shift; say "arg Num: $NumString"; $NumString =~ s/[^0-9]//g; say "s Num: $NumString"; my $count = $NumString =~ tr/0-9/0-9/; say "count: $count"; $count == 11 or die "non-conforming ABN. Please check."; say "tr Num: $NumString"; my $Numset = []; while( $NumString =~ m/([0-9])/g ){ push @$Numset, [$1]; } print_oset( $Numset, 1 ); return( $Numset ); } sub weighting_oset{ #my $woset = [[[0],[1]],[10]]; my $woset = [[10]]; push @$woset, map { $_ %2 == 1 ? [$_] : () } ( 1..19 ); print_oset( $woset ); return $woset; } sub print_oset{ my $Numset = shift; say "oset: ",@$Numset if @_; # $_[0] == 1; say "oset: \[", map("[@$_],", @$Numset), "\]"; } ##### From OP ####### sub Check_ABN { my $number = shift ; my $abn_invalid = 0 ; my $sum = 0 ; $number =~ s/\ //g ; unless (length($number) eq 11) { $abn_invalid = 1 ; return $abn_invalid ; } $sum += (substr($number,0,1)-1)*10 ; $sum += substr($number,1,1)*1 ; $sum += substr($number,2,1)*3 ; $sum += substr($number,3,1)*5 ; $sum += substr($number,4,1)*7 ; $sum += substr($number,5,1)*9 ; $sum += substr($number,6,1)*11 ; $sum += substr($number,7,1)*13 ; $sum += substr($number,8,1)*15 ; $sum += substr($number,9,1)*17 ; $sum += substr($number,10,1)*19 ; if ($sum % 89 eq 0) { return $abn_invalid ; } else { # $abn_error = 1 ; return $abn_invalid ; } # see https://abr.business.gov.au/Help/AbnFormat }



*work in Progress*

Unlike Perl6, objects in Perl5 are a matter of terminology, rather than an implicit construct of the language.citation needed

~ Belief in Objects is a practised meditation here at the monastery.

At this stage you have a general understanding of programmatic concepts of perl. Including, but not limited to:add links to examples of concepts

  • Variables
  • Data types
  • Subroutines - especially argument passing
  • Symbols - especially names and references
  • Program Flow
  • and a sprinkle of importing

A subroutine takes a list as an argument. This translates into flattened interpolation of array variables. The remedy to which is to pass array variables in by reference.

# example of pass by reference

Another way to do this instead of passing the ref as an argument, is to call the subroutine on the ref. As code tricks go, this can get fairly dangerous fairly quickly. So as an intention any ref you would like to be able to have this ability will need to be anointed.

To anoint a variable reference it is blessed.anoint vs bless meanings look up required

# bless $var;

Now we have another way to call the subroutine. We start by dereferencing the reference, but instead of making an element access, we replace the index identifier with the subroutine to be called.

$arrvar->[0]; # deref array element access $arrvar->{'anoint'}; # deref hash element access $arrvar->subroutine; # deref subroutine call

TODO: separate out the element access and subroutine call, and explain why

not actually dereferencing, just uses the same symbol in a similar way, to act in a different way. A Symbolic Synonymcitation needed of sorts

$arrvar->subroutine; # deref subroutine call

theres a couple of notes to make here. the dereference is not accessing an element, and considering you are calling a subroutine on an array, you might expect that the array is magically passed into the argument list. well. it is not. hmmph

However, what is passed in, as the first argument, is the reference. Instant Data! Yippee! All you need do now is treat the ref as you would any normal ref argument.

The responsibility now lays in the subroutine. The subroutine will need to be house-trained. If you start feeding it all sorts of garbage, your carpets will look all sorts of messy. That is, the subroutine should be expecting the data it is receiving - of which it is the recipient.

sub iexpectanarraycontainingdataaboutaccuracy{ my $arrayref = shift; ## todo: not ideal example ## also align 0/9 with degugging levels print {STDOUT} $arrayref->[0]," is quite accurate\n" print {STDOUT} $arrayref->[9]," is deeply inaccurate\n" return 1; }

wheres the second note?

should you pass an hash reference by error, firstly, you did not bless an hash reference yet so that is unlikely, secondly, messy carpets.

This is a good time to think about writing a separate script to run tests against your script. Necessary ?

ah here it is!

Is that inheritance tax seems decidedly simple

Another consequence of invoking a subroutine on a blessed reference, is that the reference can only call subroutines that exist within the same package. At least in this case, as only the reference has been blessed in the one-argument form of bless. Suffice to say, this prevents the problem of that newly blessed reference being able to call random subroutines from other loaded packages.

But to stress again, it may call any routines in the same namespace, so you should also be aware to write the other subroutines to fail correctly should they be called erroneously

#!perl use 5.10.1; use strict; use warnings; use Carp; my @array_var = qw/Double, double toil and trouble;/; say join "\n","\nfirst:", @array_var; add_an_item( \ @array_var, $_ ) foreach qw/1234 abyzABYZ 4the5scottish6play 1when 2shall 3we 4three +!/; say join "\n","\nsecond: ",@array_var; my $array_ref = \ @array_var; bless $array_ref; $array_ref->add_an_item( $_ ) foreach qw/1234 Fire burn, and cauldron bubble./; say join "\n","\nthird: ", @array_var, "\nfourth: ", @$array_ref; sub add_an_item{ say "\nsub args: ", join ' ', @_; my $avref = shift; my $item_to_add = shift; # <STDIN> # use input module or this $item_to_add =~ tr/a-zA-Z//cd; $item_to_add || carp( "Skipping item.\nItems added to this array shou +ld contain letters." ) && return; $avref->[ @$avref ] = $item_to_add; } exit (0);

a note on inheritance

so in theory...

unless(eval{ $arrayref->can(maxstr) }){ carp $@ }else{ $arrayref->maxstr() } # carps

however..

#!perl use 5.10.1; use strict; use warnings; use Carp; use parent qw'List::Util'; ... unless( $arrayref->can('maxstr') ){ carp $@ }else{ $arrayref->maxstr() } exit; #(?) :D

Hello wa5nti and welcome to the monastery.

Where to start? There could be many reasons for this occurence, so I can only make suggestions.

I was struck by the fact that your installation was attempting to install the perldoc program. In my experience Strawberry auto installs this. I find the documentation an inextricable part of the language and its distributions.

Non-installation of perldoc in Strawberry occurs when a certain config variable is defined at install time.


=item C<versiononly>

From F<versiononly.U>:

If set, this symbol indicates that only the version-specific
components of a perl installation should be installed.
This may be useful for making a test installation of a new
version without disturbing the existing installation.
Setting versiononly is equivalent to setting installperl's -v option.

In particular, the non-versioned scripts and programs such as
a2p, c2ph, h2xs, pod2*, and perldoc are not installed
(see C<INSTALL> for a more complete list). Nor are the man
pages installed.
Usually, this is undef.

Heres a one liner to see if this variable was defined at installation.

windos% perl -Mv5.20 -Mstrict -MConfig -w -e "say $Config{versiononly} +"

Should you find this variable is defined in some way, the simplest method would most likely be to re-install taking care not to install a version dependant version.

Other than that there are a huge number of variables, that do not show up in the perl -V invocation. Given the difficulty of being able to run perldoc, you may find a look at some of the path variables in the list lead you somewhere useful.

#!perl use 5.20; use strict; use warnings; use Config qw/config_sh/; open my $fh, '>', '.\configlist.txt' or die $!; print {$fh} config_sh(); close $fh;

This will provide a list something along the form of what can be seen here Example Config Variable Listing (note: Example is defined as relating to use in this forum reply, not the code itself).

Maybe check libpath variables in this list, and also permissions on the directories the paths indicate. For TMP paths, I usually see a shortname as upper case suffixed with tilde V:\STRAWB~\lib\path\

Pod is included with modules, you can check the scripts directly, and Pod is accessible through online sources CPAN Perl5

Perl is Perl, if none of this helps, maybe consider re-installing Active-State, as it was working for you previously, until you are more familiar with the language.

I hope this helps. Local access to all the really useful beginners documentation is essential for a good learning experience.


Why are you re-inventing the wheel? So I can test it goes round!

post 3 How do I write a program that calculates the sum of all numbers to a number, n? silly response given

This response is not intended to be taken literally. :p

The sum of ALL numbers being 1/12, would the sum of all numbers up to N not be some type of a function? In the manner of

sum( N,N-1,N-2..N=1 ) = N / ( 1/12 )

Oh yes, I see now n(n+1)/2, overthinking it again.

Although that might be N * 1/12 (but is probably neither). For another undefined definition, maybe just bitmasking the sum of all numbers to length N. This could work well if soan is truly irrational.

sub donotrun_this_is_an_example{ use constant Soan = (1/12); my $bitmask = ~ -256**($n/8); return Soan & $bitmask; }

similar idea would be to return the of multiplying Soan by 10 to power of N: int( Soan*10**$n )


Alert! vague conjecture recollection syndrome and Random thought process combination.

post 2

To replace the occurence string in perl

Off the top of my head (untested), I would suggest starting with a one liner such as:

perl -pi.bak -e " use features qw/state/; state $nameshash = { 'Poole' => 1 }; s/(<.*?CIT-)(\w+)(-\w\d+.*?>)/"$1$2".$nameshash->{$2}++."$3"/ge; " bibliofile

post 1

CRC-16 algorithm

quote

print "CRC16 in hex:\n  ", unpack('H*', pack('S', $crc16)), "\n";

citation needed check pack pod.
This could be a problem caused by the use of unpack() on pack() - recalling some usage where internal representation does not necessarily behave to standards of other specifications.


post 0

  • iteration vs recursion: the iterator should do what its told. that is it should have an expected behaviour as of any particular version, though that behaviour can change. It is for the programmer to be up to date with the current usage.
  • Behaviour: can change as with anything, take for example hash behaviour, modified in regards of security (re collisions). The random nature of the iteration, should not be used as a defined behaviour, yet knowledge of that behaviour allows quick development. (uhm iteration or storage/retrieval different things?).
  • User configurable: perhaps user accessible. same thing maybe. For example, I can access symbol tables, which behave in a defined way. In general I do not need to access the stashes, but I can if I want to. A cost effective implementation, (will out perform in drag races), which can be user interactive/manipulated. (we want it to turn doughnuts). Basically, I don't want to be setting loads of flags. If I need to define the behaviour outside of the general dwimness of the iterator, I can set about writing some routines to do so. This also encourages legacy code to have documented implementations.
  • user defined operator: something along this line maybe.
  • DWIM: when I want it to invalidate on a resize operation, it should. When I don't want it to invalidate on a resize operation it should not. In my dreams, I want it do both within one.
  • TMTOWTDI: There would not be any need to write code if the compiler already knew what I wanted to do.
  • seem to be straying away from iterator behaviour a bit now...
  • Common complex usage requirement:
my %combinations = ( co1 => [ [ qw(one two three four five) ], [ qw(one one two three five) ] ], co2 => [ [ qw(one two three five seven) ], [ qw(one one two three five) ] ], co3 => [ [ qw(one two three five seven) ], [ qw(one two three four five) ] ], co4 => [ [ qw(one two three five seven) ], [ qw(one two three four five) ], [ qw(one one two three five) ] ], ); reorg($_,\%combinations) foreach(keys %combinations); sub reorg{ my($k,$h) = @_; foreach my $combiset(@{$h->{$k}}){ my @uniquesets = grep $_ =~ /\Aus/ keys %combinations; my $num = scalar(@us); foreach my $set ( @$combiset ){ $combinations{'us'.++$num } = $set unless grep @$set {<~~>} @$_, @combinations{@us}; # where {<~~>} is 'these arrays match' # or the front N indices do or ... } }

To end up with something like:

%combinations = ( co1 => [ [ qw(one two three four five) ], [ qw(one one two three five) ] ], co2 => [ [ qw(one two three five seven) ], [ qw(one one two three five) ] ], co3 => [ [ qw(one two three five seven) ], [ qw(one two three four five) ] ], co4 => [ [ qw(one two three five seven) ], [ qw(one two three four five) ], [ qw(one one two three five) ] ], us1 => [ qw(one two three four five) ], us2 => [ qw(one two three five seven) ], us3 => [ qw(one one two three five) ], );

While writing this example, I felt as though most of writing code is iterator definition. Within this example, I require several uses of iterator to define growing numbers of keys, these themselves need to be used to clarify the keys the initial map operation continues to apply the reorganising routine on the hash to. While also not then applying the new keys which have been added.

A kind of There's More Than One Way To Do What I Mean? I mean the iterator to know the keys I started with, and only iterate through them as the hash grows. I mean another iterator to build a set of unique values keyed in the original hash, and built out of the original keys values. I mean the newly built unique values to be used straight away in validation checks on the remaining keys.

If as here, I approach designing the code without considering what the internal behaviour of the iterator is, other than the existing definition that it should not be relied upon. The internal iteration behaviour may change between versions, and the code is easily maintained throughout minor transitions.

What I need from the iterator is that, a defined behaviour. If it is not of any impact as to the precise implementation, as the code is not well designed if it relies on that, then would it not be reasonable to approach implementation as a matter of cost and efficiency. What is the fastest, most cost effective implementation? Can that implementation be reasonably identified as being compatible for the next 15+ years. Can I access it and incant wizardry in the way I might with symbol tables. Such as by having a user defined operator.

Perhaps something more robust, like a Global Iterator Variable / Symbol, along the lines of ${*} or *INC,*ARGV, the match array $-[0..-1]. I don't want to be setting variables and flags in most cases. I want to have a simple concept of, don't rely on this behaviour, but this is how you can manipulate it if you want to. And consider maintainer is a must, will the code self-document?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found