Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

blokhead's scratchpad

by blokhead (Monsignor)
on Jun 01, 2004 at 18:39 UTC ( #358374=scratchpad: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    +-+-+-+-+
    |?| | | |  first step: place a photo in the "?" cell
    ...
    +---+/+-+                         ***
    |///|/|?|  
    +---+-+-+  first photo that fits is the 1x1
    
  2. or download this
    +---+-+-+
    |///|/|/|
    ...
    +---+-+-+
    |///|/|/|  
    +---+-+-+
    
  3. or download this
    {
      my %seen;
    ...
      }
    
    }
    
  4. or download this
    <table border=1>
    <tr><td></td><th>PM Markup:</th><th>Result:</th></tr>
    ...
    </td></tr>
    
    </table>
    
  5. or download this
    # input:
    #  - env = mapping of variable names to types
    ...
                
                return ( resulttype, constr1 + constr2
                                      + "type1==FuncType(type2,resulttype)
    +" );
    
  6. or download this
    # unify a list of constraints:
    #  - input = list of constraints of the form "lhs==rhs"
    ...
        ## FuncType, or other such impossible feats
        else
            croak "unification impossible!";
    
  7. or download this
    ## two containers that have the same value
    my $x = 1;
    ...
    
    $x = 5;     ## change the value in one container ...
    print $y;   ## the other container is unaffected
    
  8. or download this
    my $x = 1;
    my $y = \$x; ## $y is a reference to $x
    
    $x = 5;
    print $$y;
    
  9. or download this
    my $x = 0;
    sub { $_[0] = 5 }->($x);
    
    print "$x\n";
    
  10. or download this
    my $x = 0;
    my $y = sub { $_[0] }->($x); ## my $y = .. assignment operator
    
    $y = 5;
    print "$x\n"; ## still 0
    
  11. or download this
    my $x    = 0;
    my $arr = sub { \@_ }->($x);
    
    $arr->[0] = 5;
    print "$x\n"; # 5
    
  12. or download this
    my $arr = do {
      my $x;
    ...
    
    $arr->[0] = 5;
    print "@$arr\n"; ## 5 5
    
  13. or download this
    my $x = 0;
    map { $_ = 5 } $x;
    ...
    my $x = 0;
    grep { $_ = 5 } $x;
    print "$x\n";
    
  14. or download this
    my $x = 0;
    foreach my $y ($x) { $y = 5 }
    print "$x\n";
    
  15. or download this
    my $x = 0;
    *y = \$x;
    
    $y = 5;
    print "$x\n";
    
  16. or download this
    my @x = qw(1 2 3 4);
    *y = \@x;
    
    splice @y, 2, 1, "hi";
    print "@x\n";
    
  17. or download this
    use Lexical::Alias;
    
    ...
    
    $y = 5;
    print "$x\n";
    
  18. or download this
    my $x = 0;
    
    ...
    }
    
    print "$x\n";
    
  19. or download this
    x + (x+b) + ... + (x+(n-1)b) = k
    
    nx + b(1 + 2 + .. + (n-1)) = k
    
    nx + b(n(n-1)/2) = k
    
  20. or download this
    bn^2 + (2x-b)n - 2k = 0
    
  21. or download this
    my $p = UnorderedSetPartition->new(
               items => ['a'..'f'],
    ...
    ## code repetition here?
    
    $how_many_partitions = $p->count;
    
  22. or download this
    sub binomial {
        my ($n, $k) = @_;
    ...
        }
        $c;
    }
    
  23. or download this
    use Memoize;
    memoize 'int_partitions';
    ...
    }
    
    print int_partitions(shift), $/;
    
  24. or download this
    use Memoize;
    memoize 'restricted_partitions';
    ...
    }
    
    print restricted_partitions(@ARGV), $/;
    
  25. or download this
    --- mysqlPP.pm.orig     2005-02-16 23:40:15.000000000 -0600
    +++ mysqlPP.pm  2005-02-16 23:41:17.000000000 -0600
    ...
            }
            my $mysql = $sth->FETCH('mysqlpp_handle');
            my $result = eval {
    
  26. or download this
    $sth = $dbh->prepare("select * from foo where id=?");
    $sth->execute( param("id") );
    
    ## execute failed: called with 0 bind variables when 1 are needed
    
  27. or download this
    # use CGI 'param'; ## not anymore!
    use CGI; sub param { scalar CGI::param(@_) }
    
  28. or download this
    "Robert "Bob" Smith","42","FooBar"
    
  29. or download this
    use Text::xSV;
    
    ...
    }
    
    my $csv = Text::xSV->new( filename => "...", filter => \&filter );
    
  30. or download this
    --- xSV-old.pm  2004-05-26 20:13:12.000000000 -0500
    +++ xSV.pm      2004-05-26 20:32:48.000000000 -0500
    ...
     );
     foreach my $accessor (@normal_accessors) {
       no strict 'refs';
    

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 lurking in the Monastery: (9)
As of 2014-12-29 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (188 votes), past polls