perl:index
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| perl:index [2009/08/14 07:28] – tkbletsc | perl:index [2010/01/08 13:50] (current) – tkbletsc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Perl code snippets ====== | ====== Perl code snippets ====== | ||
| + | * [[Prototype class for OO]] | ||
| * [[Real CSV Parsing]] | * [[Real CSV Parsing]] | ||
| * [[ANSI color]] | * [[ANSI color]] | ||
| Line 15: | Line 16: | ||
| * [[Single document web server]] | * [[Single document web server]] | ||
| * [[Read password without echo]] | * [[Read password without echo]] | ||
| + | * [[Amazon preview leech]] | ||
| ====== Blobs of code ====== | ====== Blobs of code ====== | ||
| Line 24: | Line 26: | ||
| sub sum { my $r=0; for (@_) { $r += $_ }; return $r; } | sub sum { my $r=0; for (@_) { $r += $_ }; return $r; } | ||
| sub avg { return sum(@_)/@_; } | sub avg { return sum(@_)/@_; } | ||
| + | sub stdev { | ||
| + | my $s=0; | ||
| + | my $avg = avg(@_); | ||
| + | foreach (@_){ | ||
| + | $s += ($_ - $avg)**2; | ||
| + | } | ||
| + | return sqrt($s/ | ||
| + | } | ||
| sub limits { | sub limits { | ||
| my $lo = my $hi = $_[0]; | my $lo = my $hi = $_[0]; | ||
| Line 67: | Line 77: | ||
| '< | '< | ||
| } | } | ||
| + | |||
| + | sub size_units { | ||
| + | my ($n) = @_; | ||
| + | if ($n> | ||
| + | if ($n> | ||
| + | if ($n> | ||
| + | if ($n> | ||
| + | return $n; | ||
| + | } | ||
| + | |||
| + | sub parse_size_units { | ||
| + | my ($s) = @_; | ||
| + | if ($s=~/ | ||
| + | if ($2 eq ' | ||
| + | elsif ($2 eq ' | ||
| + | elsif ($2 eq ' | ||
| + | elsif ($2 eq ' | ||
| + | else | ||
| + | } else { | ||
| + | return undef; | ||
| + | } | ||
| + | } | ||
| + | |||
perl/index.1250260092.txt.gz · Last modified: by tkbletsc
