# [ pOnseq(2) > = 9, 25, 16 #{ _ _ , _ _ , _ _ } @2 = [ , , ] # 1\ 1\ 0\ # 4 4 0 # 4 8 4 # 8 8 # 4 4 # #### #!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' }; } #### $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 . . . #### || ||| ||||| ||||||| ||||||||||||||| ||||||||||||||||||||||||||||||||||||||||||| 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 . . . #### cpanm (App::cpanminus) 1.7044 on perl 5.014002 built for MSWin32-x86-multi-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::Harness" "-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 author 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 CPU) # 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 CPU) 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 #### DB<2> s Capture::Tiny::capture((eval 40)[C:/Dwimperl/perl/site/lib/Capture/Tiny.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" => $unlink_on_close, 1386: "suffixlen" => length($options{'SUFFIX'}), 1387: "ErrStr" => \$errstr, 1388: "use_exlock" => $options{EXLOCK}, 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:210): 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,$path,$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_success 0 undef DB<31> #### #!/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 } #### # example of pass by reference #### # bless $var; #### $arrvar->[0]; # deref array element access $arrvar->{'anoint'}; # deref hash element access $arrvar->subroutine; # deref subroutine call #### $arrvar->subroutine; # deref subroutine call #### 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; } #### #!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; # # use input module or this $item_to_add =~ tr/a-zA-Z//cd; $item_to_add || carp( "Skipping item.\nItems added to this array should contain letters." ) && return; $avref->[ @$avref ] = $item_to_add; } exit (0); #### unless(eval{ $arrayref->can(maxstr) }){ carp $@ }else{ $arrayref->maxstr() } # carps #### #!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 #### windos% perl -Mv5.20 -Mstrict -MConfig -w -e "say $Config{versiononly}" #### #!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; #### sub donotrun_this_is_an_example{ use constant Soan = (1/12); my $bitmask = ~ -256**($n/8); return Soan & $bitmask; } #### perl -pi.bak -e " use features qw/state/; state $nameshash = { 'Poole' => 1 }; s/(<.*?CIT-)(\w+)(-\w\d+.*?>)/"$1$2".$nameshash->{$2}++."$3"/ge; " bibliofile #### 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 ... } } #### %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) ], );