Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

ambrus's scratchpad

by ambrus (Abbot)
on Jun 01, 2004 at 17:41 UTC ( #358307=scratchpad: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @seen = (0)x@adj_index;
    
  2. or download this
    @previous = (undef)x@adj_index;
    
  3. or download this
    @queue = (undex)x@adj_index;
    $queue_head = 0;
    $queue_tail = 0;
    
  4. or download this
    $found_goal = 0;
    sub visit {
    ...
            }
        }
    }
    
  5. or download this
    seeword(-1, $start);
    
  6. or download this
    while ($queue_head < $queue_tail && !$found_goal) {
        my $i = $queue[$queue_head++];
    ...
            visit($i, $j);
        }
    }
    
  7. or download this
    if ($found_goal) {
        my $i = $goal;
    ...
    } else {
        print "no word ladder.\n";
    }
    
  8. or download this
    #include <cstdlib>
    #include <iostream>
    ...
    }
    
    
  9. or download this
    203527 <+termbot> +bcc vowel.c
    203529 <+termbot> -Borland C++  Version 3.1 Copyright (c) 1992 Borland
    + 
    ...
    205654 <+termbot> - }
    205655 <+termbot> -
    205655 <+termbot> -C:\MONKPERL>
    
  10. or download this
    use warnings;
    use Scalar::Util "blessed";
    ...
    }
    
    __END__
    
  11. or download this
    creature weight negative
    
  12. or download this
    #include <stdio.h>
    int main(void) {
    ...
        }
        return 0;
    }
    
  13. or download this
    first line
    second
    third
    fourth
    
  14. or download this
    use warnings; use strict;
    
    ...
    
    __DATA__
    Some text here
    
  15. or download this
    /* css for ambrus in perlmonks.com */
    /* color, supplementing the Dark theme */
    ...
    /*.nnt-line-incidental .nnt-link { background-color: orange; }*/
    /*ul ul ul { padding-left: 0px }*/
    /* body#id-11911 .nodelets { display: none } */
    
  16. or download this
    use warnings; use strict;                                             
    +         
    no warnings qw"void";                                                 
    +         
    ...
    DEBUG;
    warn "normal message";
    __END__
    
  17. or download this
    # bash functions for manipulating the path
    
    ...
    }
    
    #END
    
  18. or download this
    [am]king ~/a/tmp$ cat a.pl
    { 
    ...
    Internet, point your browser at http://www.perl.org/, the Perl Home Pa
    +ge.
    
    [am]king ~/a/tmp$ 
    
  19. or download this
    $ perl -we 'my %rule = ("suffix1", "foo", "succ1", "bar"); warn join("
    +/", @rule{qw"suffix1 succ1"})'
    Scalar value @rule{qw"suffix1 succ1"} better written as $rule{qw"suffi
    +x1 succ1"} at -e line 1.
    ...
    This is perl, v5.10.1 (*) built for x86_64-linux
    
    ...
    
  20. or download this
    perl -le'$==1,(1x$_)=~/(^)(1|11\1)*(?{$=++})^/,print$=for 0..20'
    
  21. or download this
    perl -we 'use warnings; use strict; use 5.010; use IO "Socket"; use So
    +cket; use Fcntl; my($L, $R) = IO::Socket->socketpair(PF_UNIX, SOCK_ST
    +REAM, 0) or die; $L->fcntl(F_SETFD, $L->fcntl(F_GETFD, 0) &~ FD_CLOEX
    +EC); defined(my $p = fork) or die "fork"; if (!$p) { exec @ARGV, $L->
    +fileno; die "exec"; } $L->close; print "reading... "; my $x = $R->get
    +line; say "got: $x"; 0 < waitpid $p,0 or die "wait";' perl -we 'use w
    +arnings; use strict; use 5.010; use IO::Socket; sleep 1; my $h = shif
    +t; say "fileno: $h"; my $O = IO::Socket->new_from_fd($h, ">") or die 
    +"fdopen $!"; $O->printflush("hello"); $O->shutdown(SHUT_WR); say "wri
    +tten"; sleep 1; say "done";'
    
  22. or download this
    perl -we 'use Socket; use IO::Handle; socket $C, PF_INET(), SOCK_STREA
    +M(), 0 or die; connect $C, sockaddr_in(6667, inet_aton("irc.freenode.
    +net")) or die; printf $C "user 0 0 0 x\nnick cbu%04x\njoin #cbstream\
    +n", rand(2**16) or die; flush $C; while (<$C>) { y/\r//; /\A(?::\S+)?
    +\s+(?:4|ERROR)/ and die $_; /\A:cbstream!\S+\s+PRIVMSG\s+#cbstream\s+
    +:?(.*)/si and print $1; }'
    
  23. or download this
    perl -we 'use Socket; use IO::Handle; socket $C, PF_INET(), SOCK_STREA
    +M(), 0 or die; connect $C, sockaddr_in(6667, inet_aton("irc.freenode.
    +net")) or die; printf $C "user 0 0 0 x\nnick cbu%04x\njoin #cbstream\
    +n", rand(2**16) or die; flush $C; while (<$C>) { y/\r//; /\A(?::\S+)?
    +\s+(?:4(?!77)|ERROR)/ and die $_; /\A:cbstream!\S+\s+PRIVMSG\s+#cbstr
    +eam\s+:?(.*)/si and print $1; }'
    
  24. or download this
       442  thorns(19+7+14+17+13+18) also(0+11+18+14) An(0+13) thistlez(19
    ++7+8+18+19+11+4+25) gun(6+20+13) it(8+19) brin(1+17+8+13) forth(5+14+
    +17+19+7) 2 u(20);  -- Genesis 3:18
       442  Ceiling(2+4+8+11+8+13+6) Cat(2+0+19) sed(18+4+3), "yr(24+17) h
    +er(7+4+17) bukkit(1+20+10+10+8+19) holder(7+14+11+3+4+17), go(6+14) h
    +old(7+14+11+3) her(7+4+17) bukkit(1+20+10+10+8+19)." -- Genesis 16:9
    ...
       442  Oh(14+7) hai(7+0+8). Dude(3+20+3+4) called(2+0+11+11+4+3) Job(
    +9+14+1) replied(17+4+15+11+8+4+3) on(14+13) chat(2+7+0+19) and(0+13+3
    +) sed(18+4+3) back(1+0+2+10) to(19+14) Invisible(8+13+21+8+18+8+1+11+
    +4) Man(12+0+13): -- Job 42:1
       442  u(20) is(8+18) on(14+13) teh(19+4+7) thrones(19+7+17+14+13+4+1
    +8), gettin(6+4+19+19+8+13) praised(15+17+0+8+18+4+3) by(1+24) teh(19+
    +4+7) Israel(8+18+17+0+4+11). -- Psalm 22:3
       442  Ceiling(2+4+8+11+8+13+6) cat(2+0+19) are(0+17+4) serious(18+4+
    +17+8+14+20+18) cat(2+0+19). This(19+7+8+18) are(0+17+4) serious(18+4+
    +17+8+14+20+18) psalm(15+18+0+11+12). -- Psalm 24:8
    
  25. or download this
    /* css for ambrus in perlmonks.com */
    /* general */
    ...
    /*"http://cruft.de/lr.css"*/
    /*tbody[id="XP_Nodelet"] { display: none; color: lime }*/
    
  26. or download this
    perl -we '($H,$W)=`stty size`=~/^(\d+) (\d+)/?($1-1,$2):(24,80);$w=$W+
    +20; @a = map { rand() < 1/5 } 0 .. ($H+20)*$w; print "\e[H\e[J"; whil
    +e() { print "\e[H"; for (1..5) { rand(40)<1 and @a[rand(@a)] = 1; @a 
    += map { $c = $_; $s = 0; $s += $a[($c + $_) % @a] for -$w-1, -$w, -$w
    ++1, -1, 1, $w-1, $w, $w+1; $p = $a[$_]; ($p?2:4) <= $s && $s < ($p?6:
    +9) } 0 .. @a - 1; } for $y (10 .. $H + 9) { for $x (10 .. $W + 9) { p
    +rint $a[$y*$w + $x] ? "#" : " "; } print "\n"; } }'
    
  27. or download this
    [am]king ~$ perl -we 'use strict; { package S; use Tie::Scalar; @{*ISA
    +} = "Tie::StdScalar"; sub STORE { $::sum -= ${$_[0]}||0; $::sum += ${
    +$_[0]} = $_[1] } } my @x; tie $x[$_], "S" for 0..2; $::sum = 0; $x[ra
    +nd(10)] = int(rand(10)) for 0..99; $"="+"; warn "$::sum = @x[0..2]";'
    13 = 2+8+3 at -e line 1.
    [am]king ~$ 
    
  28. or download this
    #!ruby -w
    # simple vector-based paint program -- by ambrus
    ...
    
    __END__
    
  29. or download this
                                      +                                   
    +          
                     +++++++++++++++++++                                  
    +          
    ...
                          ++++++++++++                           +++++++++
    ++         
                         +++++++++++++                           +++++++++
    ++         
    
  30. or download this
    sub mask {
            my($s, $m) = @_;
            [map { $$s[$_] } grep { 0 != ($m & (1<<$_)) } 0 .. @$s - 1];
    }
    
  31. or download this
    a="for b=2,26 do c=0;for d,e in ipairs({a:byte(1,-1)})do c=(b*c+e)%127
    +\
    end;io.write(string.char(c))end--$S`U$-}OPX41,@aYH\3\26Q2\23*|>";
    loadstring(a)    {ambrus}
    
  32. or download this
    #!perl
    # simulate the regexp /(a(?:|(?1)|a(?1)))/
    ...
            } 
    }
    __END__
    
  33. or download this
    without memoization
      aaaaaaaa: hit, sub called 8 times
    ...
    with memoization
      aaaaaaaa: hit, sub called 8 times
      aaaaaaaab: miss, sub called 16 times
    
  34. or download this
    [am]king ~/a$ perl -we 'do { $u = 0; print "$_: ", /^((?{$u++})(?:a|aa
    +))+$/ ? "hit" : "miss", ", parens called $u times\n" } for qw"aaaaaaa
    +aa aaaaaaaaab";'
    aaaaaaaaa: hit, parens called 10 times
    aaaaaaaaab: miss, parens called 20 times
    
  35. or download this
    [am]king ~/a$ perl -we 'do { $u = 0; print "$_: ", /^((??{$u++;""})(?:
    +a|aa))+$/ ? "hit" : "miss", ", parens called $u times\n" } for qw"aaa
    +aaaaaa aaaaaaaaab";'
    aaaaaaaaa: hit, parens called 10 times
    aaaaaaaaab: miss, parens called 143 times
    
  36. or download this
    [am]king ~/a$ perl -we 'do { $u = 0; print "$_: ", /j(.)rd((?{$u++})(?
    +:\1|\1\1))+j/ ? "hit" : "miss", ", parens called $u times\n" } for qw
    +"jard"."a"x16 ."bjord"."o"x16 ."j";'
    jardaaaaaaaaaaaaaaaabjordooooooooooooooooj: hit, parens called 4197 ti
    +mes
    [am]king ~/a$ perl -we 'do { $u = 0; print "$_: ", /j(.)rd((?{$u++})(?
    +:[ao]|[ao][ao]))+j/ ? "hit" : "miss", ", parens called $u times\n" } 
    +for qw"jard"."a"x16 ."bjord"."o"x16 ."j";'
    jardaaaaaaaaaaaaaaaabjordooooooooooooooooj: hit, parens called 76 time
    +s
    
  37. or download this
    print {;log=>} "hi";
    
  38. or download this
    perl -we 'use File::Find; finddepth sub {{ /\A(\d{5}-p)(\d+)(\.tif)\z/
    + or next; my $n = sprintf("%s%04d%s", $1, $2, $3); -e $n and next; wa
    +rn "$_ => $n\n"; rename $_, $n or die "error rename $_ $n: $!"; }}, "
    +.";'
    
  39. or download this
    // 323 - Self reproducing program by Ambrus ZSBAN
    //
    ...
        }
    
    
  40. or download this
    #!/usr/local/bin/ruby -w
    
    ...
    
    __END__
    
  41. or download this
    #!/usr/bin/perl -T
    use warnings; use strict; 
    ...
    
    __END__
    
  42. or download this
    docbook -> texinfo => dvi => postscript -> pdf;
    dvi => pdf -> postscript;
    ...
    latex -> html; 
    docbook => html;
    docbook -> pdf;
    
  43. or download this
    [am]king ~$ perl -we 'while (!eof(STDIN)) { my $line = <STDIN> if 0 ==
    + @x % 3; push @x, \$line; print \$line, ": ", ($line || 0), "\n"; }; 
    +' <<<$'a\nb\n'
    SCALAR(0x812c9c0): a
    ...
    SCALAR(0x812c9a8): 0
    SCALAR(0x812c9a8): 0
    [am]king ~$ 
    
  44. or download this
    UTF-8
    
    ...
           and 0xffff (UCS non-characters) should not appear in  conformin
    +g  UTF-8
           streams.
    
  45. or download this
    switches=/f
    device=himem.sys /testmem:off
    device=ramdrive.sys 16384 512 /e
    

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 avoiding work at the Monastery: (5)
As of 2014-09-18 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (101 votes), past polls