Top Banner
*{"Abuse Perl"} = sub { "by Casey West\n" }; print "Abuse Perl"->(); Perl beta beta abuse
39
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Abuse Perl

*{"Abuse Perl"} = sub { "by Casey West\n"};

print "Abuse Perl"->();

Perl betabeta

abuse

Page 2: Abuse Perl

*{''} = sub { print "Abuse Perl by Casey West\n"};

<<_->()

_

Perl betabeta

abuse

Page 3: Abuse Perl

*{''} = sub { print shift };

<<_->(<<_)

_Abuse Perl by Casey West_

# via Abigail

Perl betabeta

abuse

Page 4: Abuse Perl

*{''} = sub { print "Abuse Perl by Casey West\n"};

''->();

Perl betabeta

abuse

Page 5: Abuse Perl

package Employee;use base 'Class::Accessor::Fast';

Employee->mk_accessors qw[name title];

sub as_string { my $self = shift; sprintf "%s: %s\n", $self->title, $self->name;}

Perl betabeta

abuse

Page 6: Abuse Perl

$casey = Employee->new({ name => "Casey West", title => "Member of Technical Staff",});

print $casey->as_string;

#Member of Technical Staff: Casey West

Perl betabeta

abuse

Page 7: Abuse Perl

*Employee::as_string = sub { my $self = shift; sprintf "%s is a %s\n", $self->name, $self->title;};

print $casey->as_string;

#Casey West is a Member of Technical Staff

Perl betabeta

abuse

Page 8: Abuse Perl

INIT { *Employee::as_string = sub { my $self = shift; sprintf "%s is a %s\n", $self->name, $self->title; };}

Perl betabeta

abuse

Page 9: Abuse Perl

INIT { *Employee::as_string_orig = *Employee::as_string;

*Employee::as_string = sub { uc shift->as_string_orig; };}

Perl betabeta

abuse

Page 10: Abuse Perl

INIT { *Employee::as_string_orig = \&Employee::as_string;

*Employee::as_string = sub { uc shift->as_string_orig; };}

Perl betabeta

abuse

Page 11: Abuse Perl

package FollowVar;use Tie::Scalar;

@ISA = ('Tie::StdScalar');

sub FETCH { warn ">>> Called at " . join(':', caller) . "\n"; return shift->SUPER::FETCH(@_);}

Perl betabeta

abuse

Page 12: Abuse Perl

tie $name, 'FollowVar';$name = "Casey West";

print Email::Address->new( $name, '[email protected]', ''), "\n";

# >>> Called at Email::Address:# /Library/Perl/5.8.6/Email/Address.pm:# 216# Casey West <[email protected]>

Perl betabeta

abuse

Page 13: Abuse Perl

package FollowHash;use Tie::Hash; @ISA = ('Tie::StdHash');

for my $sub (qw[FETCH STORE DELETE CLEAR FIRSTKEY NEXTKEY]) { *{$sub} = sub { $self = shift; $call = join':', (caller)[0,2]; $args = join',', map{$_ || 'undef'}@_;

warn ">>> $sub($args) by [$call]\n"; $sup = "SUPER::$sub"; $self->$sup(@_); }}

Perl betabeta

abuse

Page 14: Abuse Perl

use Template;

tie %vars, 'FollowHash';

%vars = (name => "Casey West");

Template->new->process(\<<__TT__, \%vars);Hello, my name is [% name %].__TT__

Perl betabeta

abuse

Page 15: Abuse Perl

CLEAR() by [main:23]STORE(name,Casey West) by [main:23]STORE(template, Template::Document=HASH(0x1866920)) by [Template::Service:79]FETCH(import) by [Template::Stash:448]FIRSTKEY() by [Template::Stash:456]NEXTKEY(template) by [Template::Stash:456]NEXTKEY(name) by [Template::Stash:456]FETCH(template) by [Template::Stash:456]FETCH(name) by [Template::Stash:456]DELETE(template) by [Template::Service:128]Hello, my name is Casey West.

Perl betabeta

abuse

Page 16: Abuse Perl

sub parse_sheet_save {

my ($rest, $linetype, $coord, $type, $value, $valuetype, $formula, $style, $namename, $namedesc, $fontnum, $layoutnum, $colornum, $check, $maxrow, $maxcol, $row, $col);

my ($lines, $sheetdata) = @_;

my $errortext;

# Initialize sheetdata structure # ...

Perl betabeta

abuse

Page 17: Abuse Perl

# # # # # # # # ### $ok = parse_sheet_save(\@lines, \%sheetdata)## Sheet input routine. Fills %sheetdata given lines of text @lines.## Currently always returns nothing.## Sheet save format:## linetype:param1:param2:...## Linetypes are:## version:versionname - version of this format. Currently 1.3.## cell:coord:type:value...:type:value... - Types are as follows:## v:value - straight numeric value# t:value - straight text/wiki-text in cell, encoded to handle \, :, newlines# vt:fulltype:value - value with value type/subtype# vtf:fulltype:value:formulatext - formula resulting in value with value type/subtype, value and text encoded# vtc:fulltype:value:valuetext - formatted text constant resulting in value with value type/subtype, value and text encoded# vf:fvalue:formulatext - formula resulting in value, value and text encoded (obsolete: only pre format version 1.1)# fvalue - first char is "N" for numeric value, "T" for text value, "H" for HTML value, rest is the value# e:errortext - Error text. Non-blank means formula parsing/calculation results in error.# b:topborder#:rightborder#:bottomborder#:leftborder# - border# in sheet border list or blank if none# l:layout# - number in cell layout list# f:font# - number in sheet fonts list# c:color# - sheet color list index for text# bg:color# - sheet color list index for background color# cf:format# - sheet cell format number for explicit format (align:left, etc.)# cvf:valueformat# - sheet cell value format number (obsolete: only pre format v1.2)# tvf:valueformat# - sheet cell text value format number# ntvf:valueformat# - sheet cell non-text value format number# colspan:numcols - number of columns spanned in merged cell# rowspan:numrows - number of rows spanned in merged cell# cssc:classname - name of CSS class to be used for cell when published instead of one calculated here# csss:styletext - explicit CSS style information, encoded to handle :, etc.# mod:allow - if "y" allow modification of cell for live "view" recalc## col:# w:widthval - number, "auto" (no width in <col> tag), number%, or blank (use default)# hide: - yes/no, no is assumed if missing# row:# hide - yes/no, no is assumed if missing## sheet:# c:lastcol - number# r:lastrow - number# w:defaultcolwidth - number, "auto", number%, or blank (default->80)# h:defaultrowheight - not used# tf:format# - cell format number for sheet default for text values# ntf:format# - cell format number for sheet default for non-text values (i.e., numbers)# layout:layout# - default cell layout number in cell layout list# font:font# - default font number in sheet font list# vf:valueformat# - default number value format number in sheet valueformat list (obsolete: only pre format version 1.2)# ntvf:valueformat# - default non-text (number) value format number in sheet valueformat list# tvf:valueformat# - default text value format number in sheet valueformat list# color:color# - default number for text color in sheet color list# bgcolor:color# - default number for background color in sheet color list# circularreferencecell:coord - cell coord with a circular reference# recalc:value - on/off (on is default). If "on", appropriate changes to the sheet cause a recalc# needsrecalc:value - yes/no (no is default). If "yes", formula values are not up to date## name:name:description:value - name definition, name in uppercase, with value being "B5", "A1:B7", or "=formula"# font:fontnum:value - text of font definition (style weight size family) for font fontnum# "*" for "style weight", size, or family, means use default (first look to sheet, then builtin)# color:colornum:rgbvalue - text of color definition (e.g., rgb(255,255,255)) for color colornum# border:bordernum:value - text of border definition (thickness style color) for border bordernum# layout:layoutnum:value - text of vertical alignment and padding style for cell layout layoutnum:# vertical-alignment:vavalue;padding topval rightval bottomval leftval;# cellformat:cformatnum:value - text of cell alignment (left/center/right) for cellformat cformatnum# valueformat:vformatnum:value - text of number format (see format_value_for_display) for valueformat vformatnum (changed in v1.2)# clipboardrange:upperleftcoord:bottomrightcoord - origin of clipboard data. Not present if clipboard empty.# There must be a clipboardrange before any clipboard lines# clipboard:coord:type:value:... - clipboard data, in same format as cell data## The resulting $sheetdata data structure is as follows:## $sheetdata{version} - version of save file read in# $sheetdata{datatypes}->{$coord} - Origin of {datavalues} value:# v - typed in numeric value of some sort, constant, no formula# t - typed in text, constant, no formula# f - result of formula calculation ({formulas} has formula to calculate)# c - constant of some sort with typed in text in {formulas} and value in {datavalues}# $sheetdata{formulas}->{$coord} - Text of formula if {datatypes} is "f", no leading "=", or text of constant if "c"# $sheetdata{datavalues}->{$coord} - a text or numeric value ready to be formatted for display or used in calculation# $sheetdata{valuetypes}->{$coord} - the value type of the datavalue as 1 or more characters# First char is "n" for numeric or "t" for text# Second chars, if present, are sub-type, like "l" for logical (0=false, 1=true)# $sheetdata{cellerrors}->{$coord} - If non-blank, error text for error in formula calculation# $sheetdata{cellattribs}->{$coord}-># {coord} - coord of cell - existence means non-blank cell# {bt}, {br}, {bb}, {bl} - border number or null if no border# {layout} - cell layout number or blank for default# {font} - font number or blank for default# {color} - color number for text or blank for default# {bgcolor} - color number for the cell background or blank for default# {cellformat} - cell format number if not default - controls horizontal alignment# {textvalueformat} - value format number if not default - controls how the cell's text values are formatted into text for display# {nontextvalueformat} - value format number if not default - controls how the cell's non-text values are turned into text for display# {colspan}, {rowspan} - column span and row span for merged cells or blank for 1# {cssc}, {csss} - explicit CSS class and CSS style for cell# {mod} - if "y" allow modification in live view# $sheetdata{colattribs}->{$colcoord}-># {width} - column width if not default# {hide} - hide column if yes# $sheetdata{rowattribs}->{$rowcoord}-># {height} - ignored# {hide} - hide row if yes# $sheetdata{sheetattribs}->{$attrib}-># {lastcol} - number of columns in sheet# {lastrow} - number of rows in sheet (more may be displayed when editing)# {defaultcolwidth} - number, "auto", number%, or blank (default->80)# {defaultrowheight} - not used# {defaulttextformat} - cell format number for sheet default for text values# {defaultnontextformat} - cell format number for sheet default for non-text values (i.e., numbers)# {defaultlayout} - default cell layout number in sheet cell layout list# {defaultfont} - default font number in sheet font list# {defaulttextvalueformat} - default text value format number in sheet valueformat list# {defaultnontextvalueformat} - default number value format number in sheet valueformat list# {defaultcolor} - default number for text color in sheet color list# {defaultbgcolor} - default number for background color in sheet color list# {circularreferencecell} - cell coord with a circular reference# {recalc} - on/off (on is default). If "on", appropriate changes to the sheet cause a recalc# {needsrecalc} - yes/no (no is default). If "yes", formula values are not up to date# $sheetdata{names}->{$name}-> - name is uppercase# {desc} - description (optional)# {definiton} - in the form of B5, A1:B7, or =formula# $sheetdata{fonts}->[$index] - font specifications addressable by array position# $sheetdata{fonthash}->{$value} - hash with font specification as keys and {fonts}->[] index position as values# $sheetdata{colors}->[$index] - color specifications addressable by array position# $sheetdata{colorhash}->{$value} - hash with color specification as keys and {colors}->[] index position as values# $sheetdata{borderstyles}->[$index] - border style specifications addressable by array position# $sheetdata{borderstylehash}->{$value} - hash with border style specification as keys and {borderstyles}->[] index position as values# $sheetdata{layoutstyles}->[$index] - cell layout specifications addressable by array position# $sheetdata{layoutstylehash}->{$value} - hash with cell layout specification as keys and {layoutstyle}->[] index position as values# $sheetdata{cellformats}->[$index] - cell format specifications addressable by array position# $sheetdata{cellformathash}->{$value} - hash with cell format specification as keys and {cellformats}->[] index position as values# $sheetdata{valueformats}->[$index] - value format specifications addressable by array position# $sheetdata{valueformathash}->{$value} - hash with value format specification as keys and {valueformats}->[] index position as values# $sheetdata{clipboard}-> - the sheet's clipboard# {range} - coord:coord range of where the clipboard contents came from or null if empty# {datavalues} - like $sheetdata{datavalues} but for clipboard copy of cells# {datatypes} - like $sheetdata{datatypes} but for clipboard copy of cells# {valuetypes} - like $sheetdata{valuetypes} but for clipboard copy of cells# {formulas} - like $sheetdata{formulas} but for clipboard copy of cells# {cellerrors} - like $sheetdata{cellerrors} but for clipboard copy of cells# {cellattribs} - like $sheetdata{cellattribs} but for clipboard copy of cells# $sheetdata{loaderror} - if non-blank, there was an error loading this sheet and this is the text of that error## # # # # # # # #

Perl betabeta

abuse

Page 18: Abuse Perl

# $sheetdata{sheetattribs}->{$attrib}-># {lastcol} - number of columns in sheet# {lastrow} - number of rows in sheet # (more may be displayed when editing)# {defaultcolwidth} - number, "auto", # number%, or blank (default->80)# {defaultrowheight} - not used# {defaulttextformat} - cell format # number for sheet default for text # values

Perl betabeta

abuse

Page 19: Abuse Perl

package Lab; use Data::Dumper;

$PKG = 'SocialCalc::Sheet';$FUNC = 'parse_sheet_save';$SYM = "$PKG\::$FUNC";$ORIG = "$SYM\_orig";

eval "require $PKG;"; *$ORIG = \&{$SYM}; *$SYM = sub{ print(Dumper("INPUT", [@_])); my @res = $ORIG->(@_); print(Dumper("OUTPUT", [@res])); return @res;};

Perl betabeta

abuse

Page 20: Abuse Perl

require App::SocialCalc;use Lab;do shift;

# perl -I $HOME -I lib# ~/lab.pl bin/socialcalc.pl

Perl betabeta

abuse

Page 21: Abuse Perl

$VAR1 = 'INPUT';$VAR2 = [ [ 'version:1.3', 'cell:A1:t:= A page to try some of wikiCalc\'s features =\\n\\nYou can use this page to ...' ] ];$VAR1 = 'OUTPUT';$VAR2 = [ '14' ];

Perl betabeta

abuse

Page 22: Abuse Perl

# # # # # # # # ### $ok = parse_sheet_save(\@lines, \%sheetdata)## Sheet input routine. Fills %sheetdata given lines of text @lines.## Currently always returns nothing.## Sheet save format:## linetype:param1:param2:...## Linetypes are:## version:versionname - version of this format. Currently 1.3.## cell:coord:type:value...:type:value... - Types are as follows:## v:value - straight numeric value# t:value - straight text/wiki-text in cell, encoded to handle \, :, newlines# vt:fulltype:value - value with value type/subtype# vtf:fulltype:value:formulatext - formula resulting in value with value type/subtype, value and text encoded# vtc:fulltype:value:valuetext - formatted text constant resulting in value with value type/subtype, value and text encoded# vf:fvalue:formulatext - formula resulting in value, value and text encoded (obsolete: only pre format version 1.1)# fvalue - first char is "N" for numeric value, "T" for text value, "H" for HTML value, rest is the value# e:errortext - Error text. Non-blank means formula parsing/calculation results in error.# b:topborder#:rightborder#:bottomborder#:leftborder# - border# in sheet border list or blank if none# l:layout# - number in cell layout list# f:font# - number in sheet fonts list# c:color# - sheet color list index for text# bg:color# - sheet color list index for background color# cf:format# - sheet cell format number for explicit format (align:left, etc.)# cvf:valueformat# - sheet cell value format number (obsolete: only pre format v1.2)# tvf:valueformat# - sheet cell text value format number# ntvf:valueformat# - sheet cell non-text value format number# colspan:numcols - number of columns spanned in merged cell# rowspan:numrows - number of rows spanned in merged cell# cssc:classname - name of CSS class to be used for cell when published instead of one calculated here# csss:styletext - explicit CSS style information, encoded to handle :, etc.# mod:allow - if "y" allow modification of cell for live "view" recalc## col:# w:widthval - number, "auto" (no width in <col> tag), number%, or blank (use default)# hide: - yes/no, no is assumed if missing# row:# hide - yes/no, no is assumed if missing## sheet:# c:lastcol - number# r:lastrow - number# w:defaultcolwidth - number, "auto", number%, or blank (default->80)# h:defaultrowheight - not used# tf:format# - cell format number for sheet default for text values# ntf:format# - cell format number for sheet default for non-text values (i.e., numbers)# layout:layout# - default cell layout number in cell layout list# font:font# - default font number in sheet font list# vf:valueformat# - default number value format number in sheet valueformat list (obsolete: only pre format version 1.2)# ntvf:valueformat# - default non-text (number) value format number in sheet valueformat list# tvf:valueformat# - default text value format number in sheet valueformat list# color:color# - default number for text color in sheet color list# bgcolor:color# - default number for background color in sheet color list# circularreferencecell:coord - cell coord with a circular reference# recalc:value - on/off (on is default). If "on", appropriate changes to the sheet cause a recalc# needsrecalc:value - yes/no (no is default). If "yes", formula values are not up to date## name:name:description:value - name definition, name in uppercase, with value being "B5", "A1:B7", or "=formula"# font:fontnum:value - text of font definition (style weight size family) for font fontnum# "*" for "style weight", size, or family, means use default (first look to sheet, then builtin)# color:colornum:rgbvalue - text of color definition (e.g., rgb(255,255,255)) for color colornum# border:bordernum:value - text of border definition (thickness style color) for border bordernum# layout:layoutnum:value - text of vertical alignment and padding style for cell layout layoutnum:# vertical-alignment:vavalue;padding topval rightval bottomval leftval;# cellformat:cformatnum:value - text of cell alignment (left/center/right) for cellformat cformatnum# valueformat:vformatnum:value - text of number format (see format_value_for_display) for valueformat vformatnum (changed in v1.2)# clipboardrange:upperleftcoord:bottomrightcoord - origin of clipboard data. Not present if clipboard empty.# There must be a clipboardrange before any clipboard lines# clipboard:coord:type:value:... - clipboard data, in same format as cell data## The resulting $sheetdata data structure is as follows:## $sheetdata{version} - version of save file read in# $sheetdata{datatypes}->{$coord} - Origin of {datavalues} value:# v - typed in numeric value of some sort, constant, no formula# t - typed in text, constant, no formula# f - result of formula calculation ({formulas} has formula to calculate)# c - constant of some sort with typed in text in {formulas} and value in {datavalues}# $sheetdata{formulas}->{$coord} - Text of formula if {datatypes} is "f", no leading "=", or text of constant if "c"# $sheetdata{datavalues}->{$coord} - a text or numeric value ready to be formatted for display or used in calculation# $sheetdata{valuetypes}->{$coord} - the value type of the datavalue as 1 or more characters# First char is "n" for numeric or "t" for text# Second chars, if present, are sub-type, like "l" for logical (0=false, 1=true)# $sheetdata{cellerrors}->{$coord} - If non-blank, error text for error in formula calculation# $sheetdata{cellattribs}->{$coord}-># {coord} - coord of cell - existence means non-blank cell# {bt}, {br}, {bb}, {bl} - border number or null if no border# {layout} - cell layout number or blank for default# {font} - font number or blank for default# {color} - color number for text or blank for default# {bgcolor} - color number for the cell background or blank for default# {cellformat} - cell format number if not default - controls horizontal alignment# {textvalueformat} - value format number if not default - controls how the cell's text values are formatted into text for display# {nontextvalueformat} - value format number if not default - controls how the cell's non-text values are turned into text for display# {colspan}, {rowspan} - column span and row span for merged cells or blank for 1# {cssc}, {csss} - explicit CSS class and CSS style for cell# {mod} - if "y" allow modification in live view# $sheetdata{colattribs}->{$colcoord}-># {width} - column width if not default# {hide} - hide column if yes# $sheetdata{rowattribs}->{$rowcoord}-># {height} - ignored# {hide} - hide row if yes# $sheetdata{sheetattribs}->{$attrib}-># {lastcol} - number of columns in sheet# {lastrow} - number of rows in sheet (more may be displayed when editing)# {defaultcolwidth} - number, "auto", number%, or blank (default->80)# {defaultrowheight} - not used# {defaulttextformat} - cell format number for sheet default for text values# {defaultnontextformat} - cell format number for sheet default for non-text values (i.e., numbers)# {defaultlayout} - default cell layout number in sheet cell layout list# {defaultfont} - default font number in sheet font list# {defaulttextvalueformat} - default text value format number in sheet valueformat list# {defaultnontextvalueformat} - default number value format number in sheet valueformat list# {defaultcolor} - default number for text color in sheet color list# {defaultbgcolor} - default number for background color in sheet color list# {circularreferencecell} - cell coord with a circular reference# {recalc} - on/off (on is default). If "on", appropriate changes to the sheet cause a recalc# {needsrecalc} - yes/no (no is default). If "yes", formula values are not up to date# $sheetdata{names}->{$name}-> - name is uppercase# {desc} - description (optional)# {definiton} - in the form of B5, A1:B7, or =formula# $sheetdata{fonts}->[$index] - font specifications addressable by array position# $sheetdata{fonthash}->{$value} - hash with font specification as keys and {fonts}->[] index position as values# $sheetdata{colors}->[$index] - color specifications addressable by array position# $sheetdata{colorhash}->{$value} - hash with color specification as keys and {colors}->[] index position as values# $sheetdata{borderstyles}->[$index] - border style specifications addressable by array position# $sheetdata{borderstylehash}->{$value} - hash with border style specification as keys and {borderstyles}->[] index position as values# $sheetdata{layoutstyles}->[$index] - cell layout specifications addressable by array position# $sheetdata{layoutstylehash}->{$value} - hash with cell layout specification as keys and {layoutstyle}->[] index position as values# $sheetdata{cellformats}->[$index] - cell format specifications addressable by array position# $sheetdata{cellformathash}->{$value} - hash with cell format specification as keys and {cellformats}->[] index position as values# $sheetdata{valueformats}->[$index] - value format specifications addressable by array position# $sheetdata{valueformathash}->{$value} - hash with value format specification as keys and {valueformats}->[] index position as values# $sheetdata{clipboard}-> - the sheet's clipboard# {range} - coord:coord range of where the clipboard contents came from or null if empty# {datavalues} - like $sheetdata{datavalues} but for clipboard copy of cells# {datatypes} - like $sheetdata{datatypes} but for clipboard copy of cells# {valuetypes} - like $sheetdata{valuetypes} but for clipboard copy of cells# {formulas} - like $sheetdata{formulas} but for clipboard copy of cells# {cellerrors} - like $sheetdata{cellerrors} but for clipboard copy of cells# {cellattribs} - like $sheetdata{cellattribs} but for clipboard copy of cells# $sheetdata{loaderror} - if non-blank, there was an error loading this sheet and this is the text of that error## # # # # # # # #

Perl betabeta

abuse

Page 23: Abuse Perl

*$SYM = sub{ my @res = $ORIG->(@_);

print Dumper $_[1]; # sheetdata

return @res;};

Perl betabeta

abuse

Page 24: Abuse Perl

$VAR1 = { 'sheetattribs' => { 'lastcol' => '8', 'lastrow' => '14' }, 'fonthash' => { '* x-small *' => 2, 'normal bold * *' => 1 }, 'cellattribs' => { 'A1' => { 'color' => '3', 'colspan' => '8', 'coord' => 'A1', 'font' => '2'

Perl betabeta

abuse

Page 25: Abuse Perl

use Net::SMTP;

$smtp = Net::SMTP->new('iminuremail.com');

# ...

Perl betabeta

abuse

Page 26: Abuse Perl

Perl betabeta

abuse

Page 27: Abuse Perl

use Net::SMTP;

$smtp = Net::SMTP->new( 'iminuremail.com', SSL => 1, Port => 465,);

# ...

Perl betabeta

abuse

Page 28: Abuse Perl

use Net::SMTP::SSL;

$smtp = Net::SMTP::SSL->new( 'iminuremail.com');

# ...

Perl betabeta

abuse

Page 29: Abuse Perl

package Net::SMTP;

@ISA = qw[Net::Cmd IO::Socket::INET];

sub new { my $self = shift; # ... return $self->SUPER::new(@_);}

Perl betabeta

abuse

Page 30: Abuse Perl

package Net::SMTP::SSL;

use base qw[IO::Socket::SSL Net::SMTP];

Perl betabeta

abuse

Page 31: Abuse Perl

package Net::SMTP::SSL;

use base qw[Net::SMTP IO::Socket::SSL];

Perl betabeta

abuse

Page 32: Abuse Perl

package Net::SMTP::SSL;

use base 'Net::SMTP';

@Net::SMTP::ISA = map { $_ eq 'IO::Socket::INET' ? 'IO::Socket::SSL' : $_} @Net::SMTP::ISA;

Perl betabeta

abuse

Page 33: Abuse Perl

package Net::SMTP::SSL;use IO::Socket::SSL;use Net::SMTP;

@ISA = ( 'IO::Socket::SSL', grep { $_ ne 'IO::Socket::INET' } @Net::SMTP::ISA );

for ( keys %Net::SMTP:: ) { next unless defined *{$Net::SMTP::{$_}}{CODE}; *{$_} = \&{"Net::SMTP::$_"};}

Perl betabeta

abuse

Page 34: Abuse Perl

package String;

use overload '""' => sub { ${+shift} };

sub new { bless \$_[1], $_[0] }sub length { length(${+shift}) }sub exclaim { uc(${+shift}) . '!!1' }

Perl betabeta

abuse

Page 35: Abuse Perl

print "Casey West"->()->length;

print "never touch them together"->()->exclaim;

sub AUTOLOAD { ($m) = ($::AUTOLOAD =~ /.+::(.+)/); String->new($m);}

# 10# NEVER TOUCH THEM TOGETHER!!1

Perl betabeta

abuse

Page 36: Abuse Perl

$me = "Casey West"->();print $me->length;print $me->exclaim;print $me;

# 10# CASEY WEST!!1# Casey West

Perl betabeta

abuse

Page 37: Abuse Perl

new $me "Casey West Sr";print "$me is " . $me->length;

# Casey West Sr is 13

Perl betabeta

abuse

Page 38: Abuse Perl

sub new { ref($_[0]) ? ${$_[0]} = $_[1] : bless \$_[1], $_[0] ;}

Perl betabeta

abuse

Page 39: Abuse Perl

print &Thanks, &for, &coming, &to, &my, &talk, "\n";

sub AUTOLOAD { ($w) = ($::AUTOLOAD =~ /.*::(.+)/); "$w ";}

Perl beta

abuse

beta