use With; my $foo = "a string"; print "before with: $foo\n"; with($foo) { s/a /not a /; } print "after with: $foo\n"; with(foo) { sub new { bless {}, shift; } } print foo->new; __output__ before with: a string after with: not a string foo=HASH(0x80fbbf0)