Add to @INC

You might need to add a path to @INC for Perl on some hosts:

BEGIN{push @INC, "/home/user/perl/usr/lib/perl5/site_perl/5.8.7";}

Posted 20 Aug 2007, tagged with perl

Favicons

The following will work under any modern browser (IE included):

<link rel="shortcut icon" href="/favicon.ico"
  type="image/vnd.microsoft.icon" />
<link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
  1. link must be inside head
  2. /favicon.ico is a legacy name and path that older browsers will sniff regardless of the above code
  3. type may be image/gif or image/png (but it doesn't work in IE)

Posted 16 Apr 2008, tagged with html browsers ie ie6 photoshop

Function arguments in Perl

a.k.a. URGHHH...

The three ways you want to remember are:

  1. If you don't know exactly what's coming, roll it all in a hash:

    sub perlFunc {
      my %args = @_;
      print $args{what_was_that_again};
    
      return(%args);
    }
    
  2. Or, if you do know what's coming:

    sub otherPerlFunc {
      my ($what_was_that_again, $oh_yeah, $never_mind) = @_;
    }
    
  3. And finally, if it's a single parameter you might as well just:

    sub oneMorePerlFunc {
      my $singleValue = shift;
    }
    

Posted 03 Aug 2007, tagged with perl

Command line calculator

echo 2/20 | bc -l

No, really.

Posted 06 Sep 2007, tagged with shell