Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Perl Golf 101

by chargrill (Parson)
on May 26, 2006 at 14:43 UTC ( #551876=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my(%s,$y,$l,$t,$d);
    
  2. or download this
    my $k = k(\%s);
    
  3. or download this
    $k = k();
    
  4. or download this
    $k=&k;
    
  5. or download this
    $k=k;
    
  6. or download this
    my $l = $d / int(length($t) / $k) / 100;
    
  7. or download this
    $l = $d / int(length($t) / $k) / 100;
    
  8. or download this
    $l = $d / 100 / int length($t)/ $k;  
    
  9. or download this
    $* = $d / $t=~y///c / $k;
    
  10. or download this
    sub i{
      my ($g,$l,$t) = @_;
      my @c;
      ...
    }
    
  11. or download this
    sub i{
      my ($g,@c) = @_;
      ...
    }
    
  12. or download this
    for(3..6){u($_)}
    
  13. or download this
    u($_)for 3..6;
    
  14. or download this
    while(<STDIN>){$t.=lc$_}
    
  15. or download this
    $t.=lc for<>;
    
  16. or download this
    push @_, shift;
    
  17. or download this
    push@$_, shift@$_ for @AoA;
    
  18. or download this
    my $n = t($_,$k);
    my %n = f($n);
    
  19. or download this
    %n = f(t($_));
    
  20. or download this
    %n = f t$_;
    
  21. or download this
    for(0..($k-1)){
      my $n = t($_,$k);
    ...
      my @g = b(1,\%n);
      $y   .= i(\@g,$l,\%t)
    }
    
  22. or download this
    map{
      %n = f t$_;
      @g = b\%n,1;
      $y .= i\@g
    } 0..$k-1;
    
  23. or download this
    @array = routine1($param1,$param2);
    $result = join ':', @array;
    
  24. or download this
    $result = join ':', @{routine1($param1,$param2)}
    
  25. or download this
    for((split//,$t)){
      my $l = (split //,$y)[$c];
    ...
      $o   .= $p >= 0 ? $a[$p] : $_;
      $c   += $c < $k-1 ? 1 : -$k+1
    }
    
  26. or download this
    map{
      $p  = index((join '', @{($y=~/./g)[$c]} ), $_);
      $o .= $p < 0 ? $_ : $a[$p];
      $c += $c < $k-1 ? 1 : 1-$k
    } $t =~ /./gs;
    
  27. or download this
    for(a..z){
      if( ! $d{$_} ){
        $d{$_} = 0
      }
    }
    
  28. or download this
    # no, you don't need a space between the 0 and the for.
    $d{$_} ||= 0for a..z;
    
  29. or download this
    my @k = map { $_->[1] } sort { $b->[0] <=> $a->[0] } @c;
    my $r = $k[0];
    $r =~ s/([a-z])\s\(.*/$1/;
    return $r
    
  30. or download this
    return( map{ $_->[1] } sort { $b->[0] <=> $a->[0] } @c )[0]
    
  31. or download this
    sub b{
      my( $e, $l ) = @_;
    ...
      }
      return @g
    }
    
  32. or download this
    sub b {
      my( $e, $l, @g) = @_;
      push @g, [ $_, (split //,'#' x int($$l{$_} * $e))] for sort keys %$l
    +;
      @g
    }
    
  33. or download this
    sub f{
      my %d;
    ...
      }
      return %d
    }
    
  34. or download this
    sub f{
      my %d;
    ...
      $d{$_} ||= 0for a..z;
      %d
    }
    
  35. or download this
    sub i{
      my ($g,$l,$t) = @_;
    ...
      $r =~ s/([a-z])\s\(.*/$1/;
      return $r
    }
    
  36. or download this
    sub i{
      my ($g,@c) = @_;
      map{ push @c, o(v($g), $$g[0][0]); w($g) } 0..25;
      ( map{ $_->[1] } sort { $b->[0] <=> $a->[0] } @c )[0]
    }
    
  37. or download this
    sub k{
      my $s = shift;
    ...
      }
      return c(@g)
    }
    
  38. or download this
    sub k{
      my @g;
    ...
      }
      c@g
    }
    
  39. or download this
    sub o{
      my ($g,$w) = @_;
    ...
      }
      return [$c,$w]
    }
    
  40. or download this
    sub o{
      my ($g,$w,$c) = @_;
    ...
      } @$g;
      [$c,$w]
    }
    
  41. or download this
    sub t{
      my ($o,$k) = @_;
    ...
      $r =~ s/[^a-z]//g;
      return $r
    }
    
  42. or download this
    sub t{
      my ($o) = @_;
    ...
      $r =~ s/[^a-z]//g;
      $r
    }
    
  43. or download this
    sub v {
      my ($m,$l,$t) = @_;
    ...
      }
      return $s
    }
    
  44. or download this
    sub v{
      $m = pop;
    ...
         } @$m;
      $s
    }
    
  45. or download this
    $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s
    +plit//=>$*
    ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$#
    +C]=$/;($#C
    >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^
    +$$C[$%++]}
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://551876]
Approved by Limbic~Region
Front-paged by liverpole
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2019-11-15 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (80 votes). Check out past polls.

    Notices?