Help for this page

Select Code to Download


  1. or download this
      # typical hash-of-hashes:
      my %hash = ( a => { b => 2 },
                   c => { b => 4 } );
      $hash{$key1}{$key2} = $value;
    
  2. or download this
      while ( my ( $outer_key, $outer_value ) = each %hash )
      {
    ...
              # do whatever...
          }
      }
    
  3. or download this
      # with dups
      my @inner_keys = map { keys %$_ } values %hash;
    ...
          }
          keys %inner_keys;
      };
    
  4. or download this
    perl -lwe 'sub f { my $n = shift;
                       return $n < 2 ? 1 : $n * f($n-1); }
               print f(7);
               eval { print f(8); };
               if ( $@ ) { print "eval failed: $@" }'
    
  5. or download this
    #!/bin/bash -x
    
    ...
        next=mutated$(( $i + 1 )).plx
        cp $this $next
    done;
    
  6. or download this
    ./mutated1.plx: eval: line 1: unexpected EOF while looking for matchin
    +g `"'
    ./mutated1.plx: eval: line 2: syntax error: unexpected end of file
    ./mutated1.plx: line 4: syntax error near unexpected token `.'
    ./mutated1.plx: line 4: `('`'|'-').('['^'"').('{'^'[').'\\$'.('`'|'-')
    +.('['^'#').('{'^'[').'='.('{'^'[').('^'^('`'|')')).('^'^('`'|'.')).('
    +^'^('`''
    
  7. or download this
      cmd1 arg1 arg2 arg3 && \
        cmd2 arg arg arg pirate arg arg arg
    
  8. or download this
      foreach d in $( find . -type d -depth 1 -print )
      do
        tar czf $d.tar.gz $d && \
          rm -rf $d
      done
    
  9. or download this
    $ perl -lwe '$_="[http://a|alpha] [http://b|beta]";
                 print;
    ...
                 print'
    [http://a|alpha] [http://b|beta]
    <a href="http://a">alpha</a> <a href="http://b">beta</a>
    
  10. or download this
    $ perl -lwe '$_="[http://a|alpha] [http://b|beta] [http://g]";
                 print;
    ...
    <a href="http://a">alpha</a>
     <a href="http://b">beta</a>
     <a href="http://g">http://g</a>
    
  11. or download this
    $ perl -lwe \
      '$_="[http://a|alpha] [http://b|beta] [http://g]";
    ...
    <a href="http://a">alpha</a>
     <a href="http://b">beta</a>
     <a href="http://g">http://g</a>
    
  12. or download this
      my $x = join("", 0..9)x2;
      my $lx = length($x);
      my $next_mult = ($lx + 15) & ~0x0f;
      $x .= "*" x ($next_mult - $lx);
      print "|$x|\n"'
    
  13. or download this
    =item $self->add_manufacturer( %args );
    
    ...
        # still need to get actual new id here...
        return $self->{dbh}->get_latest_insert_id();
    }
    
  14. or download this
    =item my $prefix = shortest_prefix @strings;
    
    ...
    
        return $prefix;
    }
    
  15. or download this
      SELECT *
        FROM my_table AS t,
             ( SELECT MAX( date ) AS max_date
                 FROM my_table ) AS s
        WHERE t.date = s.max_date;
    
  16. or download this
      #include <limits>
      int max_int = std::numeric_limits<int>::max();
    
  17. or download this
      href="...&session=<TMPL_VAR ESCAPE="HTML" NAME="session">&mod=<TMPL_
    +VAR ESCAPE="HTML" NAME="mod">&..."
    
  18. or download this
    <tr <TMPL_IF NAME="__odd__">
          bgcolor="<TMPL_VAR NAME="odd_color" ESCAPE="HTML">"
        <TMPL_ELSE>
          bgcolor="<TMPL_VAR NAME="even_color" ESCAPE="HTML">"
        </TMPL_IF> >