Tushar Samant wrote: > Another "project" I have in mind is overriding keywords with subs > that use regexes only. For instance, chop() is easy, a wrapper on > C<s/.$//>. substr could be derived from > > "(?:" . ("." x $offset) . ")(" . ("." x $len) . ")" > > How much more can be done without using eval? sub chomp { my$sum;for(@_){$sum+=length$1 if s|($/)$||}$sum } sub chop { my$ch;for(@_){$ch=$1 if s|(.)$||}$ch } sub index { my($str,$substr,$pos) = @_; $pos += 0; $str =~ /^(.{$pos}.*?)\Q$substr\E/ ? length$1 : -1; } sub quotemeta { "\Q$_[0]" } # not really a regex sub ref { local$_=sprintf$_[0];/^(.*)\(.*\)$/?$1:'' } # not robust -- Steve Lane <sml@zfx.com> ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe